[PATCH 1/8] sptests/spcache01: Detect write-through cache
Gedare Bloom
gedare at rtems.org
Wed Feb 26 19:25:02 UTC 2014
The logic here is that a write-through cache will have written back
the lines in vdata, whereas a write-back cache won't since there are
no cache conflicts before the invalidation. Did you run this test on a
write-through target to verify it works as expected?
On Wed, Feb 26, 2014 at 10:52 AM, Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
> ---
> testsuites/sptests/spcache01/init.c | 17 ++++++++++++++---
> testsuites/sptests/spcache01/spcache01.scn | 1 +
> 2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/testsuites/sptests/spcache01/init.c b/testsuites/sptests/spcache01/init.c
> index 9f27a79..d9eb053 100644
> --- a/testsuites/sptests/spcache01/init.c
> +++ b/testsuites/sptests/spcache01/init.c
> @@ -44,6 +44,7 @@ static void test_data_flush_and_invalidate(void)
> int n = 32;
> int i;
> size_t data_size = n * sizeof(data[0]);
> + bool write_through;
>
> printf("data cache flush and invalidate test\n");
>
> @@ -65,8 +66,15 @@ static void test_data_flush_and_invalidate(void)
>
> rtems_cache_invalidate_multiple_data_lines(&data[0], data_size);
>
> - for (i = 0; i < n; ++i) {
> - rtems_test_assert(vdata[i] == i);
> + write_through = vdata[0] == ~0;
> + if (write_through) {
> + for (i = 0; i < n; ++i) {
> + rtems_test_assert(vdata[i] == ~i);
> + }
> + } else {
> + for (i = 0; i < n; ++i) {
> + rtems_test_assert(vdata[i] == i);
> + }
> }
>
> for (i = 0; i < n; ++i) {
> @@ -82,7 +90,10 @@ static void test_data_flush_and_invalidate(void)
>
> rtems_interrupt_lock_release(&lock, level);
>
> - printf("data cache operations by line passed the test\n");
> + printf(
> + "data cache operations by line passed the test (%s cache detected)\n",
> + write_through ? "write-through" : "copy-back"
> + );
> } else {
> printf(
> "skip data cache flush and invalidate test"
> diff --git a/testsuites/sptests/spcache01/spcache01.scn b/testsuites/sptests/spcache01/spcache01.scn
> index 45ea3e5..c2f1eb6 100644
> --- a/testsuites/sptests/spcache01/spcache01.scn
> +++ b/testsuites/sptests/spcache01/spcache01.scn
> @@ -1,6 +1,7 @@
> *** TEST SPCACHE 1 ***
> data cache flush and invalidate test
> data cache operations by line passed the test
> +data cache operations by line passed the test (copy-back cache detected)
> data cache line size 32 bytes
> load 4096 bytes with flush entire data
> duration with normal cache 12660 ns
> --
> 1.7.7
>
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
More information about the devel
mailing list