pkarashchenko commented on code in PR #1168: URL: https://github.com/apache/incubator-nuttx-apps/pull/1168#discussion_r878461499
########## testing/ostest/prioinherit.c: ########## @@ -588,6 +667,61 @@ void priority_inheritance(void) dump_nfreeholders("priority_inheritance:"); } + /* Perform restoration test */ + + printf("priority_inheritance: Restoration Test:\n"); + + sem_init(&g_sem, 0, 1); + priority = COMPETING_THREAD_START_PRIORITY; + argv[0] = args[0]; + argv[1] = args[1]; + argv[2] = args[2]; + argv[3] = NULL; + + for (i = 0; i < NUMBER_OF_COMPETING_THREADS; i++) + { + g_priority_tracking[i] = 0; + snprintf(name, sizeof(name), "Task%1d", i); + snprintf(args[0], sizeof(args[0]), "%d", i); + snprintf(args[1], sizeof(args[1]), "%d", i * 10000); + snprintf(args[2], sizeof(args[2]), "%d", i == 0 ? 100000 : 1000); + + pids[i] = task_create(name, priority, 1024, adversary, + (FAR char * const *)argv); + priority += PRIORIY_SPREED; + } + + priority = COMPETING_THREAD_START_PRIORITY; + restoration_result = 0; + for (i = 0; i < NUMBER_OF_COMPETING_THREADS; i++) + { + printf("priority_inheritance: " + "Waiting for Task-%d to complete\n", i); + + waitpid(pids[i], &status, 0); + if (priority != g_priority_tracking[i]) + { + printf("priority_inheritance: " + "Task-%d Priority is %d, and was not restored to %d\n", + i, g_priority_tracking[i], priority); + + restoration_result |= 1 << i; + } + + priority += PRIORIY_SPREED; + } + + if (restoration_result != 0) + { + printf("priority_inheritance: ERROR: FAIL Priorities were not " + "correctly restored.\n"); + } + else + { + printf("priority_inheritance: PASSED Priority were correctly" + " restored.\n"); Review Comment: ```suggestion printf("priority_inheritance: PASSED Priority were correctly" " restored.\n"); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org