* \brief Semaphore test.
*
* \version $Id$
- *
+ *
* \author Daniele Basile <asterix@develer.com>
- * \author Stefano Fedrigo <aleph@develer.com>
- *
+ * \author Stefano Fedrigo <aleph@develer.com>
+ *
+ * $test$: cp bertos/cfg/cfg_proc.h $cfgdir/
+ * $test$: echo "#undef CONFIG_KERN" >> $cfgdir/cfg_proc.h
+ * $test$: echo "#define CONFIG_KERN 1" >> $cfgdir/cfg_proc.h
+ * $test$: cp bertos/cfg/cfg_sem.h $cfgdir/
+ * $test$: echo "#undef CONFIG_KERN_SEMAPHORES" >> $cfgdir/cfg_sem.h
+ * $test$: echo "#define CONFIG_KERN_SEMAPHORES 1" >> $cfgdir/cfg_sem.h
*/
#include <cfg/debug.h>
// Global settings for the test.
#define MAX_GLOBAL_COUNT 1024
#define TEST_TIME_OUT_MS 6000
-#define DELAY 5
+#define DELAY 5
// Settings for the test process.
//Process 1
/*
* These macros generate the code needed to create the test process functions.
- */
+ */
#define PROC_TEST(num) static void proc_test##num(void) \
{ \
unsigned int local_count = 0; \
ticks_t start_time = timer_clock();
kprintf("Run semaphore test..\n");
-
+
//Init the process tests
PROC_TEST_INIT(1)
PROC_TEST_INIT(2)
PROC_TEST_INIT(7)
PROC_TEST_INIT(8)
kputs("> Main: Processes created\n");
-
+
/*
- * Wait until all process finishing, if some going wrong we return
- * error after time_out_ms ms.
- */
+ * Wait until all processes exit, if something goes wrong we return an
+ * error after timeout_ms.
+ */
while((timer_clock() - start_time) < ms_to_ticks(TEST_TIME_OUT_MS))
{
if (sem_attempt(&sem))
{
- kputs("> Main: Check if test is finish..\n");
+ kputs("> Main: Check if test has finished..\n");
if(global_count == MAX_GLOBAL_COUNT)
{
kputs("> Main: Test Finished..Ok!\n");
}
proc_yield();
}
-
+
kputs("Semaphore Test fail..\n");
return -1;
}
kprintf("Init Semaphore..");
sem_init(&sem);
kprintf("Done.\n");
-
+
#if CONFIG_KERN_PREEMPT
kprintf("Init Interrupt (preempt mode)..");
irq_init();
kprintf("Init Timer..");
timer_init();
kprintf("Done.\n");
-
+
kprintf("Init Process..");
proc_init();
kprintf("Done.\n");
-
+
return 0;
}
return 0;
}
-TEST_MAIN(sem);
\ No newline at end of file
+TEST_MAIN(sem);