Changeset 34db7fa in mainline for kernel/test/fpu/mips2.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/fpu/mips2.c

    rdf496c5 r34db7fa  
    2727 */
    2828
     29#ifdef mips32
     30
    2931#include <print.h>
    3032#include <debug.h>
     
    3840#include <arch.h>
    3941
    40 #ifdef mips32
    41 
    4242#define THREADS         50
    4343#define DELAY           10000L
     
    4545
    4646static atomic_t threads_ok;
     47static atomic_t threads_fault;
    4748static waitq_t can_start;
    4849
     
    5051{
    5152        int i;
    52         int arg __attribute__((aligned(16))) = (int)((unative_t) data);
     53        int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
    5354        int after_arg __attribute__((aligned(16)));
    54 
     55       
    5556        thread_detach(THREAD);
    5657       
    5758        waitq_sleep(&can_start);
    5859
    59         for (i = 0; i<ATTEMPTS; i++) {
    60                 __asm__ volatile (
     60        for (i = 0; i < ATTEMPTS; i++) {
     61                asm volatile (
    6162                        "mtc1 %0,$1"
    62                         :"=r"(arg)
    63                         );
    64 
     63                        : "=r" (arg)
     64                );
     65               
    6566                delay(DELAY);
    66                 __asm__ volatile (
     67               
     68                asm volatile (
    6769                        "mfc1 %0, $1"
    68                         :"=r"(after_arg)
    69                         );
     70                        : "=r" (after_arg)
     71                );
    7072               
    71                 if(arg != after_arg)
    72                         panic("General reg tid%d: arg(%d) != %d\n",
    73                               THREAD->tid, arg, after_arg);
     73                if (arg != after_arg) {
     74                        printf("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     75                        atomic_inc(&threads_fault);
     76                        break;
     77                }
    7478        }
    75 
    7679        atomic_inc(&threads_ok);
    7780}
     
    8083{
    8184        int i;
    82         int arg __attribute__((aligned(16))) = (int)((unative_t) data);
     85        int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
    8386        int after_arg __attribute__((aligned(16)));
    84 
     87       
    8588        thread_detach(THREAD);
    86 
     89       
    8790        waitq_sleep(&can_start);
    8891
    89         for (i = 0; i<ATTEMPTS; i++) {
    90                 __asm__ volatile (
     92        for (i = 0; i < ATTEMPTS; i++) {
     93                asm volatile (
    9194                        "mtc1 %0,$1"
    92                         :"=r"(arg)
    93                         );
     95                        : "=r" (arg)
     96                );
    9497
    9598                scheduler();
    96                 __asm__ volatile (
     99                asm volatile (
    97100                        "mfc1 %0,$1"
    98                         :"=r"(after_arg)
    99                         );
     101                        : "=r" (after_arg)
     102                );
    100103               
    101                 if(arg != after_arg)
    102                         panic("General reg tid%d: arg(%d) != %d\n",
    103                               THREAD->tid, arg, after_arg);
     104                if (arg != after_arg) {
     105                        panic("General reg tid%d: arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     106                        atomic_inc(&threads_fault);
     107                        break;
     108                }
    104109        }
    105 
    106110        atomic_inc(&threads_ok);
    107111}
    108112
    109113
    110 void test_mips2(void)
     114char * test_mips2(void)
    111115{
    112         thread_t *t;
    113         int i;
     116        unsigned int i, total = 0;
     117       
     118        waitq_initialize(&can_start);
     119        atomic_set(&threads_ok, 0);
     120        atomic_set(&threads_fault, 0);
     121        printf("Creating %d threads... ", 2 * THREADS);
    114122
    115         waitq_initialize(&can_start);
    116 
    117         printf("MIPS test #1\n");
    118         printf("Creating %d threads... ", THREADS);
    119 
    120         for (i=0; i<THREADS/2; i++) { 
    121                 if (!(t = thread_create(testit1, (void *)((unative_t)i*2), TASK, 0, "testit1")))
    122                         panic("could not create thread\n");
     123        for (i = 0; i < THREADS; i++) {
     124                thread_t *t;
     125               
     126                if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1"))) {
     127                        printf("could not create thread %d\n", 2 * i);
     128                        break;
     129                }
    123130                thread_ready(t);
    124                 if (!(t = thread_create(testit2, (void *)((unative_t)i*2+1), TASK, 0, "testit2")))
    125                         panic("could not create thread\n");
     131                total++;
     132               
     133                if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2"))) {
     134                        printf("could not create thread %d\n", 2 * i + 1);
     135                        break;
     136                }
    126137                thread_ready(t);
     138                total++;
    127139        }
    128 
    129140        printf("ok\n");
    130        
     141               
    131142        thread_sleep(1);
    132143        waitq_wakeup(&can_start, WAKEUP_ALL);
    133 
    134         while (atomic_get(&threads_ok) != THREADS)
    135                 ;
    136                
    137         printf("Test passed.\n");
    138 }
    139 
    140 #else
    141 
    142 void test_mips2(void)
    143 {
    144         printf("This test is availaible only on MIPS32 platform.\n");
     144       
     145        while (atomic_get(&threads_ok) != total) {
     146                printf("Threads left: %d\n", total - atomic_get(&threads_ok));
     147                thread_sleep(1);
     148        }
     149       
     150        if (atomic_get(&threads_fault) == 0)
     151                return NULL;
     152       
     153        return "Test failed";
    145154}
    146155
Note: See TracChangeset for help on using the changeset viewer.