Check queued worker completion cancellation and attachment codec tests
This commit is contained in:
1 parent
0dc2b0135a
commit
14935378bb
2 files changed
+18
-1
No files matched your search
+15
-1
@@ -82,6 +82,13 @@ static void heartbeat(void* arg) {
|
||||
if (!t->heartbeat) { DEBUG_ERROR(DEBUG_CATEGORY_DM, "heartbeat allocation failed"); uasync_stop(t->ua); }
|
||||
}
|
||||
|
||||
struct cancellation_test { int worked, calls, error; };
|
||||
static void cancellation_work(void* arg) { ((struct cancellation_test*)arg)->worked = 1; }
|
||||
static void cancellation_done(void* arg, int error) {
|
||||
struct cancellation_test* test = arg;
|
||||
test->calls++; test->error = error;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
debug_config_init(); debug_set_level(DEBUG_LEVEL_ERROR);
|
||||
struct worker_test t = {0};
|
||||
@@ -93,7 +100,14 @@ int main(void) {
|
||||
if (!t.completed) uasync_mainloop(t.ua);
|
||||
if (t.heartbeat) uasync_cancel_timeout(t.ua, t.heartbeat);
|
||||
int ok = t.completed && !t.result && t.beats >= 10;
|
||||
media_async_destroy(t.ma); uasync_destroy(t.ua, 0);
|
||||
media_async_destroy(t.ma);
|
||||
struct cancellation_test cancellation = {0};
|
||||
t.ma = media_async_create();
|
||||
media_async_submit(t.ma, t.ua, cancellation_work, &cancellation, cancellation_done, &cancellation);
|
||||
media_async_destroy(t.ma); /* Join worker и отмена уже posted completion до poll. */
|
||||
uasync_poll(t.ua, 0);
|
||||
ok = ok && cancellation.worked && cancellation.calls == 1 && cancellation.error == MEDIA_ASYNC_CANCELLED;
|
||||
uasync_destroy(t.ua, 0);
|
||||
printf("test_dm_worker: 8MiB encrypt/decrypt, runs=%u heartbeat=%u max_gap=%.1fms %s\n",
|
||||
t.encryptions, t.beats, t.max_gap / 10.0, ok ? "PASS" : "FAIL");
|
||||
return !ok;
|
||||
|
||||
Reference in new issue
Block a user