diff options
author | Richard Braun <rbraun@sceen.net> | 2014-10-09 22:14:15 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2014-10-09 22:14:15 +0200 |
commit | d6bb985f9127c6bd0ff8b4b44740b04a35fd28a9 (patch) | |
tree | a157a5502b0c17a08ed9fc54b5d6ec50566e14d6 /test | |
parent | 321fd79c19d48ed57775c996af932d991901ab5a (diff) |
test: remove assertions
Don't rely on assert, use panic and error_check instead.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_llsync_defer.c | 8 | ||||
-rw-r--r-- | test/test_pmap_update_mp.c | 8 | ||||
-rw-r--r-- | test/test_sref_dirty_zeroes.c | 6 | ||||
-rw-r--r-- | test/test_sref_noref.c | 16 | ||||
-rw-r--r-- | test/test_x86_pmap_remove_ptp.c | 17 |
5 files changed, 33 insertions, 22 deletions
diff --git a/test/test_llsync_defer.c b/test/test_llsync_defer.c index 2286cb57..5a52bd4d 100644 --- a/test/test_llsync_defer.c +++ b/test/test_llsync_defer.c @@ -28,8 +28,8 @@ * Each thread regularly prints a string to report that it's making progress. */ -#include <kern/assert.h> #include <kern/condition.h> +#include <kern/error.h> #include <kern/kmem.h> #include <kern/llsync.h> #include <kern/macros.h> @@ -189,15 +189,15 @@ test_setup(void) thread_attr_init(&attr, "x15_test_alloc"); thread_attr_set_detached(&attr); error = thread_create(&thread, &attr, test_alloc, NULL); - assert(!error); + error_check(error, "thread_create"); thread_attr_init(&attr,"x15_test_free"); thread_attr_set_detached(&attr); error = thread_create(&thread, &attr, test_free, NULL); - assert(!error); + error_check(error, "thread_create"); thread_attr_init(&attr, "x15_test_read"); thread_attr_set_detached(&attr); error = thread_create(&thread, &attr, test_read, NULL); - assert(!error); + error_check(error, "thread_create"); } diff --git a/test/test_pmap_update_mp.c b/test/test_pmap_update_mp.c index bfaaac6f..975e55f5 100644 --- a/test/test_pmap_update_mp.c +++ b/test/test_pmap_update_mp.c @@ -24,9 +24,9 @@ * tables of the current processor have been updated. */ -#include <kern/assert.h> #include <kern/condition.h> #include <kern/cpumap.h> +#include <kern/error.h> #include <kern/mutex.h> #include <kern/panic.h> #include <kern/param.h> @@ -103,7 +103,7 @@ test_setup(void) test_va = 0; error = cpumap_create(&cpumap); - assert(!error); + error_check(error, "cpumap_create"); cpumap_zero(cpumap); cpumap_set(cpumap, 0); @@ -111,7 +111,7 @@ test_setup(void) thread_attr_set_detached(&attr); thread_attr_set_cpumap(&attr, cpumap); error = thread_create(&thread, &attr, test_run1, NULL); - assert(!error); + error_check(error, "thread_create"); cpumap_zero(cpumap); cpumap_set(cpumap, 1); @@ -119,7 +119,7 @@ test_setup(void) thread_attr_set_detached(&attr); thread_attr_set_cpumap(&attr, cpumap); error = thread_create(&thread, &attr, test_run2, NULL); - assert(!error); + error_check(error, "thread_create"); cpumap_destroy(cpumap); } diff --git a/test/test_sref_dirty_zeroes.c b/test/test_sref_dirty_zeroes.c index 527d5ec6..0c808c4f 100644 --- a/test/test_sref_dirty_zeroes.c +++ b/test/test_sref_dirty_zeroes.c @@ -26,8 +26,8 @@ * and panics if it is. */ -#include <kern/assert.h> #include <kern/condition.h> +#include <kern/error.h> #include <kern/evcnt.h> #include <kern/kmem.h> #include <kern/macros.h> @@ -114,10 +114,10 @@ test_setup(void) thread_attr_init(&attr, "x15_test_inc"); thread_attr_set_detached(&attr); error = thread_create(&thread, &attr, test_inc, NULL); - assert(!error); + error_check(error, "thread_create"); thread_attr_init(&attr, "x15_test_dec"); thread_attr_set_detached(&attr); error = thread_create(&thread, &attr, test_dec, NULL); - assert(!error); + error_check(error, "thread_create"); } diff --git a/test/test_sref_noref.c b/test/test_sref_noref.c index 911eb61e..208eab25 100644 --- a/test/test_sref_noref.c +++ b/test/test_sref_noref.c @@ -32,12 +32,13 @@ * to occur. */ -#include <kern/assert.h> #include <kern/condition.h> +#include <kern/error.h> #include <kern/evcnt.h> #include <kern/kmem.h> #include <kern/macros.h> #include <kern/mutex.h> +#include <kern/panic.h> #include <kern/sprintf.h> #include <kern/sref.h> #include <kern/stddef.h> @@ -120,18 +121,23 @@ test_run(void *arg) nr_threads = cpu_count() + 1; threads = kmem_alloc(sizeof(*threads) * nr_threads); - assert(threads != NULL); + + if (threads == NULL) + panic("kmem_alloc: %s", error_str(ERROR_NOMEM)); for (i = 0; i < nr_threads; i++) { snprintf(name, sizeof(name), "x15_test_ref/%u", i); thread_attr_init(&attr, name); error = thread_create(&threads[i], &attr, test_ref, NULL); - assert(!error); + error_check(error, "thread_create"); } printk("allocating page\n"); va = vm_kmem_alloc(sizeof(*obj)); - assert(va != 0); + + if (va == 0) + panic("vm_kmem_alloc: %s", error_str(ERROR_NOMEM)); + obj = (void *)va; sref_counter_init(&obj->ref_counter, test_obj_noref); @@ -170,5 +176,5 @@ test_setup(void) thread_attr_init(&attr, "x15_test_run"); thread_attr_set_detached(&attr); error = thread_create(&thread, &attr, test_run, NULL); - assert(!error); + error_check(error, "thread_create"); } diff --git a/test/test_x86_pmap_remove_ptp.c b/test/test_x86_pmap_remove_ptp.c index 601248d3..1ddb26b6 100644 --- a/test/test_x86_pmap_remove_ptp.c +++ b/test/test_x86_pmap_remove_ptp.c @@ -35,8 +35,8 @@ * behaviour. */ -#include <kern/assert.h> #include <kern/cpumap.h> +#include <kern/error.h> #include <kern/panic.h> #include <kern/param.h> #include <kern/printk.h> @@ -60,13 +60,16 @@ test_run(void *arg) printk("creating mapping\n"); page = vm_page_alloc(0, VM_PAGE_KMEM); - assert(page != NULL); + + if (page == NULL) + panic("vm_page_alloc: %s", error_str(ERROR_NOMEM)); + va = 0; flags = VM_MAP_FLAGS(VM_PROT_ALL, VM_PROT_ALL, VM_INHERIT_NONE, VM_ADV_DEFAULT, 0); error = vm_map_enter(kernel_map, NULL, 0, &va, (1UL << 22), (1UL << 22), flags); - assert(!error); + error_check(error, "vm_map_enter"); pmap_enter(kernel_pmap, va, vm_page_to_pa(page), VM_PROT_READ | VM_PROT_WRITE, PMAP_PEF_GLOBAL); pmap_update(kernel_pmap); @@ -80,7 +83,9 @@ test_run(void *arg) printk("allocating dummy physical page\n"); dummy = vm_page_alloc(0, VM_PAGE_KMEM); - assert(dummy != NULL); + + if (dummy == NULL) + panic("vm_page_alloc: %s", error_str(ERROR_NOMEM)); printk("recreating mapping\n"); pmap_enter(kernel_pmap, va, vm_page_to_pa(page), @@ -107,7 +112,7 @@ test_setup(void) */ error = cpumap_create(&cpumap); - assert(!error); + error_check(error, "cpumap_create"); cpumap_zero(cpumap); cpumap_set(cpumap, 0); @@ -117,7 +122,7 @@ test_setup(void) thread_attr_set_policy(&attr, THREAD_SCHED_POLICY_FIFO); thread_attr_set_priority(&attr, THREAD_SCHED_RT_PRIO_MAX); error = thread_create(&thread, &attr, test_run, NULL); - assert(!error); + error_check(error, "thread_create"); cpumap_destroy(cpumap); } |