Changeset af28af6 in mainline


Ignore:
Timestamp:
2025-03-06T14:59:37Z (3 days ago)
Author:
Matěj Volf <git@…>
Children:
88cbc66
Parents:
25ee7ec5
Message:

add tests pthread keys

Location:
uspace/lib
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/test/fibril/exit_hook.c

    r25ee7ec5 raf28af6  
    5858}
    5959
    60 /*
    61  * static errno_t fibril_to_be_killed(void* _arg) {
    62  *     fibril_add_exit_hook(exit_hook);
    63  *
    64  *     while (true)
    65  *         firbil_yield();
    66  *
    67  *     assert(0 && "unreachable");
    68  * }
    69  *
    70  * PCUT_TEST(exit_hook_kill) {
    71  *     value = 0;
    72  *     fid_t other = fibril_create(fibril_to_be_killed, NULL);
    73  *     fibril_start(other);
    74  *
    75  *     fibril_yield();
    76  *
    77  *     fibril_kill(other); // anything like this doesn't exist yet
    78  *
    79  *     PCUT_ASSERT_INT_EQUALS(5, value);
    80  * }
    81  */
     60static errno_t fibril_explicit_exit(void *_arg)
     61{
     62        fibril_add_exit_hook(exit_hook);
     63        fibril_exit(ETIMEOUT);
     64}
     65
     66PCUT_TEST(exit_hook_explicit_exit)
     67{
     68        value = 0;
     69        fid_t other = fibril_create(fibril_explicit_exit, NULL);
     70        fibril_start(other);
     71
     72        fibril_yield();
     73
     74        PCUT_ASSERT_INT_EQUALS(5, value);
     75}
     76
     77#ifdef FIBRIL_KILL_HAS_BEEN_IMPLEMENTED
     78static errno_t fibril_to_be_killed(void *_arg)
     79{
     80        fibril_add_exit_hook(exit_hook);
     81
     82        while (true)
     83                firbil_yield();
     84
     85        assert(0 && "unreachable");
     86}
     87
     88PCUT_TEST(exit_hook_kill)
     89{
     90        value = 0;
     91        fid_t other = fibril_create(fibril_to_be_killed, NULL);
     92        fibril_start(other);
     93
     94        fibril_yield();
     95
     96        fibril_kill(other); // anything like this doesn't exist yet
     97
     98        PCUT_ASSERT_INT_EQUALS(5, value);
     99}
     100#endif // FIBRIL_KILL_HAS_BEEN_IMPLEMENTED
    82101
    83102PCUT_EXPORT(fibril_exit_hook);
  • uspace/lib/posix/meson.build

    r25ee7ec5 raf28af6  
    6161        'test/stdlib.c',
    6262        'test/unistd.c',
     63        'test/pthread/keys.c',
    6364)
    6465
  • uspace/lib/posix/test/main.c

    r25ee7ec5 raf28af6  
    3434PCUT_IMPORT(stdlib);
    3535PCUT_IMPORT(unistd);
     36PCUT_IMPORT(pthread_keys);
    3637
    3738PCUT_MAIN();
Note: See TracChangeset for help on using the changeset viewer.