Commit 372d3d6d authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan

Isolating boot code for big test.

parent e5578b98
......@@ -27,6 +27,7 @@ config LCD_PROTOTYPE_TEST
default m
depends on LCD_PROTOTYPE_API
depends on LCD_PROTOTYPE_LIBLCD
select LCD_PROTOTYPE_TEST_BOOT
select LCD_PROTOTYPE_TEST_CUSTOMER
select LCD_PROTOTYPE_TEST_DEALER
select LCD_PROTOTYPE_TEST_MANUFACTURER
......@@ -46,6 +47,14 @@ config LCD_PROTOTYPE_TEST_MANUFACTURER
depends on LCD_PROTOTYPE_TEST
default m
config LCD_PROTOTYPE_TEST_BOOT
tristate
depends on LCD_PROTOTYPE_TEST
depends on LCD_PROTOTYPE_TEST_CUSTOMER
depends on LCD_PROTOTYPE_TEST_MANUFACTURER
depends on LCD_PROTOTYPE_TEST_DEALER
default m
config LCD_PROTOTYPE_TEST_IN_LCD
bool "LCD Prototype run tests in LCD"
depends on LCD_PROTOTYPE_TEST
......
......@@ -802,212 +802,6 @@ clean1:
return ret;
}
struct test08_info {
struct completion c;
int ret_val;
};
int manufacturer_start(void);
int dealer_start(void);
int customer_start(void);
static int test08_manufacturer(void *unused)
{
struct test08_info *i;
i = (struct test08_info *)unused;
i->ret_val = manufacturer_start();
complete(&i->c);
return 0;
}
static int test08_dealer(void *unused)
{
struct test08_info *i;
i = (struct test08_info *)unused;
i->ret_val = dealer_start();
complete(&i->c);
return 0;
}
static int test08_customer(void *unused)
{
struct test08_info *i;
i = (struct test08_info *)unused;
i->ret_val = customer_start();
complete(&i->c);
return 0;;
}
static int test08(void)
{
int ret = -1;
struct lcd *manufacturer_lcd;
struct lcd *dealer_lcd;
struct lcd *customer_lcd;
struct task_struct *manufacturer_task;
struct task_struct *dealer_task;
struct task_struct *customer_task;
struct test08_info mi;
struct test08_info di;
struct test08_info ci;
cptr_t mcptr;
cptr_t dcptr;
cptr_t ccptr;
/*
* Build lcd's
*/
manufacturer_lcd = test_mk_lcd();
if (!manufacturer_lcd) {
ret = -1;
goto clean1;
}
dealer_lcd = test_mk_lcd();
if (!dealer_lcd) {
ret = -1;
goto clean2;
}
customer_lcd = test_mk_lcd();
if (!customer_lcd) {
ret = -1;
goto clean3;
}
/*
* Create and install boot endpoint
*/
ret = lcd_cnode_alloc(dealer_lcd->cspace, &dcptr);
if (ret)
goto clean4;
if (dcptr != 1) {
ret = -1;
LCD_ERR("dealer cptr not 1, so need to change macro first");
goto clean4;
}
ret = __lcd_mk_sync_endpoint(dealer_lcd, dcptr);
if (ret)
goto clean4;
ret = lcd_cnode_alloc(manufacturer_lcd->cspace, &mcptr);
if (ret)
goto clean5;
if (mcptr != 1) {
ret = -1;
LCD_ERR("mfter cptr not 1, so need to change macro first");
goto clean5;
}
ret = lcd_cnode_grant(dealer_lcd->cspace, manufacturer_lcd->cspace,
dcptr, mcptr, LCD_CAP_RIGHT_WRITE);
if (ret)
goto clean5;
ret = lcd_cnode_alloc(customer_lcd->cspace, &ccptr);
if (ret)
goto clean5;
if (ccptr != 1) {
ret = -1;
LCD_ERR("customer cptr not 1, so need to change macro first");
goto clean5;
}
ret = lcd_cnode_grant(dealer_lcd->cspace, customer_lcd->cspace,
dcptr, ccptr, LCD_CAP_RIGHT_WRITE);
if (ret)
goto clean5;
/*
* Init completions
*/
init_completion(&mi.c);
init_completion(&di.c);
init_completion(&ci.c);
/*
* Spawn kthreads
*/
manufacturer_task = kthread_create(test08_manufacturer, &mi,
"test08_manufacturer");
if (!manufacturer_task) {
LCD_ERR("spawning manufacturer task");
goto clean5;
}
dealer_task = kthread_create(test08_dealer, &di,
"test08_dealer");
if (!dealer_task) {
LCD_ERR("spawning dealer task");
goto clean6;
}
customer_task = kthread_create(test08_customer, &ci,
"test08_customer");
if (!customer_task) {
LCD_ERR("spawning customer task");
goto clean7;
}
/*
* Install lcd's
*/
manufacturer_task->lcd = manufacturer_lcd;
manufacturer_lcd->parent = manufacturer_task;
dealer_task->lcd = dealer_lcd;
dealer_lcd->parent = dealer_task;
customer_task->lcd = customer_lcd;
customer_lcd->parent = customer_task;
/*
* Wake up threads
*/
wake_up_process(manufacturer_task);
wake_up_process(dealer_task);
wake_up_process(customer_task);
/*
* Wait for them to finish (using completions to avoid hang)
*/
wait_for_completion_interruptible(&mi.c);
wait_for_completion_interruptible(&di.c);
wait_for_completion_interruptible(&ci.c);
if (mi.ret_val) {
LCD_ERR("manufacturer non zero ret val %d",
mi.ret_val);
ret = -1;
goto clean5;
}
if (di.ret_val) {
LCD_ERR("dealer non zero ret val %d",
di.ret_val);
ret = -1;
goto clean5;
}
if (ci.ret_val) {
LCD_ERR("customer non zero ret val %d",
ci.ret_val);
ret = -1;
goto clean5;
}
ret = 0;
goto clean5;
clean7:
kthread_stop(dealer_task);
clean6:
kthread_stop(manufacturer_task);
clean5:
__lcd_rm_sync_endpoint(dealer_lcd, dcptr);
clean4:
test_rm_lcd(customer_lcd);
clean3:
test_rm_lcd(dealer_lcd);
clean2:
test_rm_lcd(manufacturer_lcd);
clean1:
return ret;
}
int api_tests(void)
{
if (test01())
......@@ -1024,8 +818,6 @@ int api_tests(void)
return -1;
if (test07())
return -1;
if (test08())
return -1;
LCD_MSG("all api tests passed!");
return 0;
}
obj-$(CONFIG_LCD_PROTOTYPE_TEST_BOOT) += lcd-prototype-test-boot.o
lcd-prototype-test-boot-y += boot.o
obj-$(CONFIG_LCD_PROTOTYPE_TEST_CUSTOMER) += lcd-prototype-test-customer.o
lcd-prototype-test-customer-y += customer.o customer-idl.o
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment