Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2018 → Rev 2019

/trunk/kernel/test/test.c
0,0 → 1,47
/*
* Copyright (C) 2006 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup test
* @{
*/
/** @file
*/
 
#include <test.h>
 
test_t tests[] = {
{
"atomic1",
"Test atomic operations",
&test_atomic1
},
{NULL, NULL, NULL}
};
 
/** @}
*/
/trunk/kernel/test/test.h
0,0 → 1,54
/*
* Copyright (C) 2006 Martin Decky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup test
* @{
*/
/** @file
*/
 
#ifndef KERN_TEST_H_
#define KERN_TEST_H_
 
#include <arch/types.h>
#include <typedefs.h>
 
typedef struct {
char * name;
char * desc;
function entry;
} test_t;
 
extern void test_atomic1(void);
 
extern test_t tests[];
 
#endif
 
/** @}
*/
/trunk/kernel/test/mm/slab2/test.c
37,6 → 37,10
#include <synch/condvar.h>
#include <synch/mutex.h>
 
#ifdef CONFIG_BENCH
#include <arch/cycle.h>
#endif
 
#define ITEM_SIZE 256
 
/** Fill memory with 2 caches, when allocation fails,
208,6 → 212,10
 
void test(void)
{
#ifdef CONFIG_BENCH
uint64_t t0 = get_cycle();
#endif
 
printf("Running reclaim single-thread test .. pass1\n");
totalmemtest();
printf("Running reclaim single-thread test .. pass2\n");
218,4 → 226,9
multitest(2048);
multitest(8192);
printf("All done.\n");
 
#ifdef CONFIG_BENCH
uint64_t dt = get_cycle() - t0;
printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
#endif
}
/trunk/kernel/test/atomic/atomic1/test.c
File deleted
/trunk/kernel/test/atomic/atomic1.c
0,0 → 1,67
/*
* Copyright (C) 2006 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <test.h>
#include <print.h>
#include <atomic.h>
#include <debug.h>
 
#ifdef CONFIG_BENCH
#include <arch/cycle.h>
#endif
 
void test_atomic1(void)
{
#ifdef CONFIG_BENCH
uint64_t t0 = get_cycle();
#endif
atomic_t a;
 
atomic_set(&a, 10);
printf("Testing atomic_set() and atomic_get().\n");
ASSERT(atomic_get(&a) == 10);
printf("Testing atomic_postinc()\n");
ASSERT(atomic_postinc(&a) == 10);
ASSERT(atomic_get(&a) == 11);
printf("Testing atomic_postdec()\n");
ASSERT(atomic_postdec(&a) == 11);
ASSERT(atomic_get(&a) == 10);
printf("Testing atomic_preinc()\n");
ASSERT(atomic_preinc(&a) == 11);
ASSERT(atomic_get(&a) == 11);
printf("Testing atomic_predec()\n");
ASSERT(atomic_postdec(&a) == 11);
ASSERT(atomic_get(&a) == 10);
 
printf("Test passed.\n");
#ifdef CONFIG_BENCH
uint64_t dt = get_cycle() - t0;
printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
#endif
return;
}
/trunk/kernel/kernel.config
118,32 → 118,8
 
## Run-time configuration directives
 
# Kernel test type
@ "" No test
@ "atomic/atomic1" Test of atomic operations.
@ "btree/btree1" B-tree test.
@ "synch/rwlock1" Read write test 1
@ "synch/rwlock2" Read write test 2
@ "synch/rwlock3" Read write test 3
@ "synch/rwlock4" Read write test 4
@ "synch/rwlock5" Read write test 5
@ "synch/semaphore1" Semaphore test 1
@ "synch/semaphore2" Sempahore test 2
@ [ARCH=ia32|ARCH=amd64|ARCH=ia64|ARCH=ia32xen] "fpu/fpu1" Intel FPU test 1
@ [ARCH=ia32|ARCH=amd64|ARCH=ia32xen] "fpu/sse1" Intel SSE test 1
@ [ARCH=mips32&MACHINE!=msim&MACHINE!=simics] "fpu/mips1" MIPS FPU test 1
@ "print/print1" Printf test 1
@ "thread/thread1" Thread test 1
@ "mm/mapping1" Mapping test 1
@ "mm/falloc1" Frame Allocation test 1
@ "mm/falloc2" Frame Allocation test 2
@ "mm/slab1" SLAB test1 - No CPU cache
@ "mm/slab2" SLAB test2 - SMP CPU cache
@ "fault/fault1" Write to NULL (maybe page fault)
@ "sysinfo" Sysinfo fill and dump test
@ [ARCH=ia64] "mm/purge1" Itanium TLB purge test
@ [ARCH=mips32] "debug/mips1" MIPS breakpoint-debug test
! CONFIG_TEST (choice)
# Compile kernel tests
! CONFIG_TEST (y/n)
 
# Benchmark test
! [CONFIG_TEST!=] CONFIG_BENCH (n/y)
# Benchmark tests
! [CONFIG_TEST!=] CONFIG_BENCH (y/n)
/trunk/kernel/generic/include/test.h
File deleted
/trunk/kernel/generic/src/main/kinit.c
70,10 → 70,6
#include <synch/waitq.h>
#include <synch/spinlock.h>
 
#ifdef CONFIG_TEST
#include <test.h>
#endif /* CONFIG_TEST */
 
/** Kernel initialization thread.
*
* kinit takes care of higher level kernel
154,11 → 150,6
 
interrupts_enable();
 
#ifdef CONFIG_TEST
test();
printf("\nTest finished, please reboot.\n");
#else /* CONFIG_TEST */
 
count_t i;
for (i = 0; i < init.cnt; i++) {
/*
194,8 → 185,6
printf("kinit... ");
}
}
#endif /* CONFIG_TEST */
 
}
 
/** @}
/trunk/kernel/generic/src/console/cmd.c
65,6 → 65,10
#include <ipc/ipc.h>
#include <ipc/irq.h>
 
#ifdef CONFIG_TEST
#include <test.h>
#endif
 
/* Data and methods for 'help' command. */
static int cmd_help(cmd_arg_t *argv);
static cmd_info_t help_info = {
76,7 → 80,7
 
static cmd_info_t exit_info = {
.name = "exit",
.description ="Exit kconsole",
.description = "Exit kconsole",
.argc = 0
};
 
83,11 → 87,38
static int cmd_continue(cmd_arg_t *argv);
static cmd_info_t continue_info = {
.name = "continue",
.description ="Return console back to userspace.",
.description = "Return console back to userspace.",
.func = cmd_continue,
.argc = 0
};
 
#ifdef CONFIG_TEST
static int cmd_tests(cmd_arg_t *argv);
static cmd_info_t tests_info = {
.name = "tests",
.description = "Print available kernel tests.",
.func = cmd_tests,
.argc = 0
};
 
static char test_buf[MAX_CMDLINE + 1];
static int cmd_test(cmd_arg_t *argv);
static cmd_arg_t test_argv[] = {
{
.type = ARG_TYPE_STRING,
.buffer = test_buf,
.len = sizeof(test_buf)
}
};
static cmd_info_t test_info = {
.name = "test",
.description = "Run kernel test.",
.func = cmd_test,
.argc = 1,
.argv = test_argv
};
#endif
 
/* Data and methods for 'description' command. */
static int cmd_desc(cmd_arg_t *argv);
static void desc_help(void);
377,6 → 408,10
&version_info,
&zones_info,
&zone_info,
#ifdef CONFIG_TEST
&tests_info,
&test_info,
#endif
NULL
};
 
805,5 → 840,46
return 1;
}
 
/** Command for printing kernel tests list.
*
* @param argv Ignored.
*
* return Always 1.
*/
int cmd_tests(cmd_arg_t *argv)
{
test_t *test;
for (test = tests; test->name != NULL; test++)
printf("%s\t%s\n", test->name, test->desc);
return 1;
}
 
/** Command for returning kernel tests
*
* @param argv Argument vector.
*
* return Always 1.
*/
int cmd_test(cmd_arg_t *argv)
{
bool fnd = false;
test_t *test;
for (test = tests; test->name != NULL; test++) {
if (strcmp(test->name, argv->buffer) == 0) {
fnd = true;
test->entry();
break;
}
}
if (!fnd)
printf("Unknown test.\n");
return 1;
}
 
/** @}
*/
/trunk/kernel/Makefile
215,7 → 215,10
 
ifneq ($(CONFIG_TEST),)
DEFS += -DCONFIG_TEST
GENERIC_SOURCES += test/$(CONFIG_TEST)/test.c
CFLAGS += -Itest/
GENERIC_SOURCES += \
test/test.c \
test/atomic/atomic1.c
endif
 
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))