Changeset 319e60e in mainline


Ignore:
Timestamp:
2006-12-11T18:33:53Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
50661ab
Parents:
134877d
Message:

prepare for new test infrastructure

Location:
kernel
Files:
1 added
5 edited
2 moved

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r134877d r319e60e  
    216216ifneq ($(CONFIG_TEST),)
    217217        DEFS += -DCONFIG_TEST
    218         GENERIC_SOURCES += test/$(CONFIG_TEST)/test.c
     218        CFLAGS += -Itest/
     219        GENERIC_SOURCES += \
     220                test/test.c \
     221                test/atomic/atomic1.c
    219222endif
    220223
  • kernel/generic/src/console/cmd.c

    r134877d r319e60e  
    6666#include <ipc/irq.h>
    6767
     68#ifdef CONFIG_TEST
     69#include <test.h>
     70#endif
     71
    6872/* Data and methods for 'help' command. */
    6973static int cmd_help(cmd_arg_t *argv);
     
    7781static cmd_info_t exit_info = {
    7882        .name = "exit",
    79         .description ="Exit kconsole",
     83        .description = "Exit kconsole",
    8084        .argc = 0
    8185};
     
    8488static cmd_info_t continue_info = {
    8589        .name = "continue",
    86         .description ="Return console back to userspace.",
     90        .description = "Return console back to userspace.",
    8791        .func = cmd_continue,
    8892        .argc = 0
    8993};
     94
     95#ifdef CONFIG_TEST
     96static int cmd_tests(cmd_arg_t *argv);
     97static cmd_info_t tests_info = {
     98        .name = "tests",
     99        .description = "Print available kernel tests.",
     100        .func = cmd_tests,
     101        .argc = 0
     102};
     103
     104static char test_buf[MAX_CMDLINE + 1];
     105static int cmd_test(cmd_arg_t *argv);
     106static cmd_arg_t test_argv[] = {
     107        {
     108                .type = ARG_TYPE_STRING,
     109                .buffer = test_buf,
     110                .len = sizeof(test_buf)
     111        }
     112};
     113static cmd_info_t test_info = {
     114        .name = "test",
     115        .description = "Run kernel test.",
     116        .func = cmd_test,
     117        .argc = 1,
     118        .argv = test_argv
     119};
     120#endif
    90121
    91122/* Data and methods for 'description' command. */
     
    378409        &zones_info,
    379410        &zone_info,
     411#ifdef CONFIG_TEST
     412        &tests_info,
     413        &test_info,
     414#endif
    380415        NULL
    381416};
     
    806841}
    807842
     843/** Command for printing kernel tests list.
     844 *
     845 * @param argv Ignored.
     846 *
     847 * return Always 1.
     848 */
     849int cmd_tests(cmd_arg_t *argv)
     850{
     851        test_t *test;
     852       
     853        for (test = tests; test->name != NULL; test++)
     854                printf("%s\t%s\n", test->name, test->desc);
     855       
     856        return 1;
     857}
     858
     859/** Command for returning kernel tests
     860 *
     861 * @param argv Argument vector.
     862 *
     863 * return Always 1.
     864 */
     865int cmd_test(cmd_arg_t *argv)
     866{
     867        bool fnd = false;
     868        test_t *test;
     869       
     870        for (test = tests; test->name != NULL; test++) {
     871                if (strcmp(test->name, argv->buffer) == 0) {
     872                        fnd = true;
     873                        test->entry();
     874                        break;
     875                }
     876        }
     877       
     878        if (!fnd)
     879                printf("Unknown test.\n");
     880       
     881        return 1;
     882}
     883
    808884/** @}
    809885 */
  • kernel/generic/src/main/kinit.c

    r134877d r319e60e  
    7070#include <synch/waitq.h>
    7171#include <synch/spinlock.h>
    72 
    73 #ifdef CONFIG_TEST
    74 #include <test.h>
    75 #endif /* CONFIG_TEST */
    7672
    7773/** Kernel initialization thread.
     
    155151        interrupts_enable();
    156152
    157 #ifdef CONFIG_TEST
    158         test();
    159         printf("\nTest finished, please reboot.\n");
    160 #else  /* CONFIG_TEST */
    161 
    162153        count_t i;
    163154        for (i = 0; i < init.cnt; i++) {
     
    195186                }
    196187        }
    197 #endif /* CONFIG_TEST */
    198 
    199188}
    200189
  • kernel/kernel.config

    r134877d r319e60e  
    119119## Run-time configuration directives
    120120
    121 # Kernel test type
    122 @ "" No test
    123 @ "atomic/atomic1" Test of atomic operations.
    124 @ "btree/btree1" B-tree test.
    125 @ "synch/rwlock1" Read write test 1
    126 @ "synch/rwlock2" Read write test 2
    127 @ "synch/rwlock3" Read write test 3
    128 @ "synch/rwlock4" Read write test 4
    129 @ "synch/rwlock5" Read write test 5
    130 @ "synch/semaphore1" Semaphore test 1
    131 @ "synch/semaphore2" Sempahore test 2
    132 @ [ARCH=ia32|ARCH=amd64|ARCH=ia64|ARCH=ia32xen] "fpu/fpu1" Intel FPU test 1
    133 @ [ARCH=ia32|ARCH=amd64|ARCH=ia32xen] "fpu/sse1" Intel SSE test 1
    134 @ [ARCH=mips32&MACHINE!=msim&MACHINE!=simics] "fpu/mips1" MIPS FPU test 1
    135 @ "print/print1" Printf test 1
    136 @ "thread/thread1" Thread test 1
    137 @ "mm/mapping1" Mapping test 1
    138 @ "mm/falloc1" Frame Allocation test 1
    139 @ "mm/falloc2" Frame Allocation test 2
    140 @ "mm/slab1" SLAB test1 - No CPU cache
    141 @ "mm/slab2" SLAB test2 - SMP CPU cache
    142 @ "fault/fault1" Write to NULL (maybe page fault)
    143 @ "sysinfo" Sysinfo fill and dump test
    144 @ [ARCH=ia64] "mm/purge1" Itanium TLB purge test
    145 @ [ARCH=mips32] "debug/mips1" MIPS breakpoint-debug test
    146 ! CONFIG_TEST (choice)
     121# Compile kernel tests
     122! CONFIG_TEST (y/n)
    147123
    148 # Benchmark test
    149 ! [CONFIG_TEST!=] CONFIG_BENCH (n/y)
     124# Benchmark tests
     125! [CONFIG_TEST!=] CONFIG_BENCH (y/n)
  • kernel/test/atomic/atomic1.c

    r134877d r319e60e  
    3232#include <debug.h>
    3333
    34 void test(void)
     34#ifdef CONFIG_BENCH
     35#include <arch/cycle.h>
     36#endif
     37
     38void test_atomic1(void)
    3539{
     40#ifdef CONFIG_BENCH
     41        uint64_t t0 = get_cycle();
     42#endif
    3643        atomic_t a;
    3744
     
    5259        ASSERT(atomic_get(&a) == 10);
    5360
    54         printf("Test passed.\n");       
     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
    5566        return;
    5667}
  • kernel/test/mm/slab2/test.c

    r134877d r319e60e  
    3838#include <synch/mutex.h>
    3939
     40#ifdef CONFIG_BENCH
     41#include <arch/cycle.h>
     42#endif
     43
    4044#define ITEM_SIZE 256
    4145
     
    209213void test(void)
    210214{
     215#ifdef CONFIG_BENCH
     216        uint64_t t0 = get_cycle();
     217#endif
     218
    211219        printf("Running reclaim single-thread test .. pass1\n");
    212220        totalmemtest();
     
    219227        multitest(8192);
    220228        printf("All done.\n");
    221 }
     229
     230#ifdef CONFIG_BENCH
     231        uint64_t dt = get_cycle() - t0;
     232        printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
     233#endif
     234}
  • kernel/test/test.h

    r134877d r319e60e  
    11/*
    2  * Copyright (C) 2001-2004 Jakub Jermar
     2 * Copyright (C) 2006 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup generic
     29/** @addtogroup test
    3030 * @{
    3131 */
     
    3636#define KERN_TEST_H_
    3737
    38 extern void test(void);
     38#include <arch/types.h>
     39#include <typedefs.h>
     40
     41typedef struct {
     42        char * name;
     43        char * desc;
     44        function entry;
     45} test_t;
     46
     47extern void test_atomic1(void);
     48
     49extern test_t tests[];
    3950
    4051#endif
Note: See TracChangeset for help on using the changeset viewer.