Changeset 9f8745c5 in mainline for kernel/test/synch/workqueue2.c


Ignore:
Timestamp:
2012-07-10T18:07:34Z (12 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b23c88e
Parents:
5b6c033
Message:

workq: Moved almost all tests to a single test entry function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/synch/workqueue2.c

    r5b6c033 r9f8745c5  
    4747
    4848
     49/*-------------------------------------------------------------------*/
     50
     51static work_t basic_work;
     52static int basic_done = 0;
     53
     54static void basic_test_work(work_t *work_item)
     55{
     56        basic_done = 1;
     57        TPRINTF("basic_test_work()");
     58}
     59
     60
     61static void basic_test(void)
     62{
     63        TPRINTF("Issue a single work item.\n");
     64        basic_done = 0;
     65        workq_global_enqueue(&basic_work, basic_test_work);
     66       
     67        while (!basic_done) {
     68                TPRINTF(".");
     69                thread_sleep(1);
     70        }
     71
     72        TPRINTF("\nBasic test done\n");
     73}
     74
     75/*-------------------------------------------------------------------*/
     76
     77
    4978struct work_queue *workq = NULL;
    5079
     
    5382        return workq_enqueue(workq, work_item, func);
    5483}
     84/*-------------------------------------------------------------------*/
    5585
    5686
    57 
    58 const char *test_workqueue2(void)
     87static const char *test_custom_workq_impl(bool stop, const char *qname)
    5988{
    60         workq = workq_create("test-workq");
     89        workq = workq_create(qname);
    6190       
    6291        if (!workq) {
    63                 return "Failed to create a work queue.";
     92                return "Failed to create a work queue.\n";
    6493        }
    6594       
    66         const char *ret = run_workq_core(false);
     95        const char *ret = run_workq_core(stop);
    6796       
    6897        TPRINTF("Stopping work queue...\n");
     
    71100        TPRINTF("Destroying work queue...\n");
    72101        workq_destroy(workq);
    73 
    74102        return ret;
    75103}
    76104
     105static const char *test_custom_workq(void)
     106{
     107        TPRINTF("Stress testing a custom queue.\n");
     108        return test_custom_workq_impl(false, "test-workq");
     109}
    77110
    78 const char *test_workqueue2stop(void)
     111
     112static const char *test_custom_workq_stop(void)
    79113{
    80         workq = workq_create("test-workq");
     114        TPRINTF("Stress testing a custom queue. Stops prematurely. "
     115                "Errors are expected.\n");
     116        test_custom_workq_impl(true, "test-workq-stop");
     117        /* Errors are expected. */
     118        return 0;
     119}
     120
     121
     122const char *test_workqueue_all(void)
     123{
     124        const char *err = 0;
     125        const char *res;
    81126       
    82         if (!workq) {
    83                 return "Failed to create a work queue.";
     127        basic_test();
     128       
     129        res = test_custom_workq();
     130        if (res) {
     131                TPRINTF(res);
     132                err = res;
    84133        }
    85134       
    86         const char *ret = run_workq_core(true);
     135        res = test_custom_workq_stop();
     136        if (res) {
     137                TPRINTF(res);
     138                err = res;
     139        }
    87140       
    88         TPRINTF("Stopping work queue...\n");
    89         workq_stop(workq);
    90        
    91         TPRINTF("Destroying work queue...\n");
    92         workq_destroy(workq);
     141        res = test_workqueue3();
     142        if (res) {
     143                TPRINTF(res);
     144                err = res;
     145        }
    93146
    94         return ret;
     147        return err;
    95148}
    96 
Note: See TracChangeset for help on using the changeset viewer.