Changeset 34db7fa in mainline for kernel/test/atomic/atomic1.c


Ignore:
Timestamp:
2006-12-12T12:32:02Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96348adc
Parents:
df496c5
Message:

cleanup kernel tests infrastructure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/atomic/atomic1.c

    rdf496c5 r34db7fa  
    3232#include <debug.h>
    3333
    34 #ifdef CONFIG_BENCH
    35 #include <arch/cycle.h>
    36 #endif
    37 
    38 void test_atomic1(void)
     34char * test_atomic1(void)
    3935{
    40 #ifdef CONFIG_BENCH
    41         uint64_t t0 = get_cycle();
    42 #endif
    4336        atomic_t a;
    44 
     37       
    4538        atomic_set(&a, 10);
    46         printf("Testing atomic_set() and atomic_get().\n");
    47         ASSERT(atomic_get(&a) == 10);
    48         printf("Testing atomic_postinc()\n");
    49         ASSERT(atomic_postinc(&a) == 10);
    50         ASSERT(atomic_get(&a) == 11);
    51         printf("Testing atomic_postdec()\n");
    52         ASSERT(atomic_postdec(&a) == 11);
    53         ASSERT(atomic_get(&a) == 10);
    54         printf("Testing atomic_preinc()\n");
    55         ASSERT(atomic_preinc(&a) == 11);
    56         ASSERT(atomic_get(&a) == 11);
    57         printf("Testing atomic_predec()\n");
    58         ASSERT(atomic_postdec(&a) == 11);
    59         ASSERT(atomic_get(&a) == 10);
    60 
    61         printf("Test passed.\n");
    62 #ifdef CONFIG_BENCH
    63         uint64_t dt = get_cycle() - t0;
    64         printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
    65 #endif
     39        if (atomic_get(&a) != 10)
     40                return "Failed atomic_set()/atomic_get()";
     41       
     42        if (atomic_postinc(&a) != 10)
     43                return "Failed atomic_postinc()";
     44        if (atomic_get(&a) != 11)
     45                return "Failed atomic_get() after atomic_postinc()";
     46       
     47        if (atomic_postdec(&a) != 11)
     48                return "Failed atomic_postdec()";
     49        if (atomic_get(&a) != 10)
     50                return "Failed atomic_get() after atomic_postdec()";
     51       
     52        if (atomic_preinc(&a) != 11)
     53                return "Failed atomic_preinc()";
     54        if (atomic_get(&a) != 11)
     55                return "Failed atomic_get() after atomic_preinc()";
     56       
     57        if (atomic_predec(&a) != 10)
     58                return "Failed atomic_predec()";
     59        if (atomic_get(&a) != 10)
     60                return "Failed atomic_get() after atomic_predec()";
     61       
     62        return NULL;
    6663}
Note: See TracChangeset for help on using the changeset viewer.