2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
13 #define TEST_NAME_PROPER_LEN 16
18 char name1
[TEST_NAME_PROPER_LEN
];
19 char name2
[TEST_NAME_PROPER_LEN
];
20 char too_long_name
[] = "thisnameistoolong";
21 char short_name
[] = "labatt50";
22 char short_name_ust
[] = "labatt50-ust";
23 char long_name
[] = "procrastinating";
24 char long_name_ust
[] = "procrastina-ust";
28 /* Get the initial thread name */
29 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
30 ok(ret
== 0, "Get the thread name: '%s'", name1
);
32 /* Set a thread name of more than 16 bytes, should fail */
33 ret
= lttng_pthread_setname_np(too_long_name
);
34 ok(ret
== ERANGE
, "Set a too long thread name: '%s'", too_long_name
);
36 /* Get the thread name again, shouldn't have changed */
37 ret
= lttng_pthread_getname_np(name2
, TEST_NAME_PROPER_LEN
);
38 ok(ret
== 0, "Get the thread name: '%s'", name2
);
39 ok(strcmp(name1
, name2
) == 0, "Compare the initial thread name: '%s' == '%s'", name1
, name2
);
41 /* Set a thread name of less than 16 bytes */
42 ret
= lttng_pthread_setname_np(short_name
);
43 ok(ret
== 0, "Set a short thread name: '%s'", short_name
);
45 /* Get the thread name again, should be the one we set */
46 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
47 ok(ret
== 0, "Get a short thread name: '%s'", name1
);
48 ok(strcmp(short_name
, name1
) == 0, "Compare the short thread name: '%s' == '%s'", short_name
, name1
);
50 /* Append "-ust" to the thread name */
51 lttng_ust_setustprocname();
52 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
53 ok(strcmp(short_name_ust
, name1
) == 0, "Compare the short UST thread name: '%s' == '%s'", short_name_ust
, name1
);
56 /* Set a thread name of 16 bytes */
57 ret
= lttng_pthread_setname_np(long_name
);
58 ok(ret
== 0, "Set a long thread name: '%s'", long_name
);
60 /* Get the thread name again, should be the one we set */
61 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
62 ok(ret
== 0, "Get a long thread name: '%s'", name1
);
63 ok(strncmp(long_name
, name1
, TEST_NAME_PROPER_LEN
- 1) == 0, "Compare the long thread name: '%s' == '%s'", long_name
, name1
);
65 /* Append "-ust" to the thread name which will truncate its end */
66 lttng_ust_setustprocname();
67 ret
= lttng_pthread_getname_np(name1
, TEST_NAME_PROPER_LEN
);
68 ok(strcmp(long_name_ust
, name1
) == 0, "Compare the long UST thread name: '%s' == '%s'", long_name_ust
, name1
);
This page took 0.047521 seconds and 4 git commands to generate.