2 * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #include "common/compat/pthread.hpp"
14 #define TEST_NAME_PROPER_LEN 16
19 char name1
[TEST_NAME_PROPER_LEN
];
20 char name2
[TEST_NAME_PROPER_LEN
];
21 char too_long_name
[] = "thisnameistoolong";
22 char short_name
[] = "labatt50";
23 char long_name
[] = "procrastinating";
27 /* Get the initial thread name */
28 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
29 ok(ret
== 0, "Get the thread name: '%s'", name1
);
31 /* Set a thread name of more than 16 bytes, should fail */
32 ret
= lttng_pthread_setname_np(too_long_name
);
33 ok(ret
== ERANGE
, "Set a too long thread name: '%s'", too_long_name
);
35 /* Get the thread name again, shouldn't have changed */
36 ret
= lttng_pthread_getname_np(name2
, TEST_NAME_PROPER_LEN
);
37 ok(ret
== 0, "Get the thread name: '%s'", name2
);
38 ok(strcmp(name1
, name2
) == 0, "Compare the initial thread name: '%s' == '%s'", name1
, name2
);
40 /* Set a thread name of less than 16 bytes */
41 ret
= lttng_pthread_setname_np(short_name
);
42 ok(ret
== 0, "Set a short thread name: '%s'", short_name
);
44 /* Get the thread name again, should be the one we set */
45 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
46 ok(ret
== 0, "Get a short thread name: '%s'", name1
);
47 ok(strcmp(short_name
, name1
) == 0,
48 "Compare the short thread name: '%s' == '%s'",
52 /* Set a thread name of 16 bytes */
53 ret
= lttng_pthread_setname_np(long_name
);
54 ok(ret
== 0, "Set a long thread name: '%s'", long_name
);
56 /* Get the thread name again, should be the one we set */
57 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
58 ok(ret
== 0, "Get a long thread name: '%s'", name1
);
59 ok(strncmp(long_name
, name1
, TEST_NAME_PROPER_LEN
- 1) == 0,
60 "Compare the long thread name: '%s' == '%s'",
This page took 0.029931 seconds and 4 git commands to generate.