Changeset 9f8745c5 in mainline for kernel/test/synch/workqueue2.c
- Timestamp:
- 2012-07-10T18:07:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b23c88e
- Parents:
- 5b6c033
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/synch/workqueue2.c
r5b6c033 r9f8745c5 47 47 48 48 49 /*-------------------------------------------------------------------*/ 50 51 static work_t basic_work; 52 static int basic_done = 0; 53 54 static void basic_test_work(work_t *work_item) 55 { 56 basic_done = 1; 57 TPRINTF("basic_test_work()"); 58 } 59 60 61 static 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 49 78 struct work_queue *workq = NULL; 50 79 … … 53 82 return workq_enqueue(workq, work_item, func); 54 83 } 84 /*-------------------------------------------------------------------*/ 55 85 56 86 57 58 const char *test_workqueue2(void) 87 static const char *test_custom_workq_impl(bool stop, const char *qname) 59 88 { 60 workq = workq_create( "test-workq");89 workq = workq_create(qname); 61 90 62 91 if (!workq) { 63 return "Failed to create a work queue. ";92 return "Failed to create a work queue.\n"; 64 93 } 65 94 66 const char *ret = run_workq_core( false);95 const char *ret = run_workq_core(stop); 67 96 68 97 TPRINTF("Stopping work queue...\n"); … … 71 100 TPRINTF("Destroying work queue...\n"); 72 101 workq_destroy(workq); 73 74 102 return ret; 75 103 } 76 104 105 static 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 } 77 110 78 const char *test_workqueue2stop(void) 111 112 static const char *test_custom_workq_stop(void) 79 113 { 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 122 const char *test_workqueue_all(void) 123 { 124 const char *err = 0; 125 const char *res; 81 126 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; 84 133 } 85 134 86 const char *ret = run_workq_core(true); 135 res = test_custom_workq_stop(); 136 if (res) { 137 TPRINTF(res); 138 err = res; 139 } 87 140 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 } 93 146 94 return ret;147 return err; 95 148 } 96
Note:
See TracChangeset
for help on using the changeset viewer.