1 /* Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; only
6 * version 2.1 of the License.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #define TEST_NAME_PROPER_LEN 16
29 char name
[TEST_NAME_PROPER_LEN
];
30 char short_name
[] = "labatt50";
31 char short_name_ust
[] = "labatt50-ust";
32 char long_name
[] = "thisnameistoolong";
33 char long_name_ust
[] = "thisnameist-ust";
37 ret
= lttng_pthread_getname_np(name
, TEST_NAME_PROPER_LEN
);
38 ok(ret
== 0, "Get the thread name: %s", name
);
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 ret
= lttng_pthread_getname_np(name
, TEST_NAME_PROPER_LEN
);
45 ok(ret
== 0, "Get a short thread name: %s", name
);
46 ok(strcmp(short_name
, name
) == 0, "Compare the short thread name: %s == %s", short_name
, name
);
48 /* Append "-ust" to the thread name */
49 lttng_ust_setustprocname();
50 ret
= lttng_pthread_getname_np(name
, TEST_NAME_PROPER_LEN
);
51 ok(strcmp(short_name_ust
, name
) == 0, "Compare the short UST thread name: %s == %s", short_name_ust
, name
);
54 /* Set a thread name of more than 16 bytes */
55 ret
= lttng_pthread_setname_np(long_name
);
56 ok(ret
== 0, "Set a long thread name: %s", long_name
);
58 ret
= lttng_pthread_getname_np(name
, TEST_NAME_PROPER_LEN
);
59 ok(ret
== 0, "Get a truncated long thread name: %s", name
);
60 ok(strncmp(long_name
, name
, TEST_NAME_PROPER_LEN
- 1) == 0, "Compare the truncated long thread name: %s == %s", long_name
, name
);
62 /* Append "-ust" to the thread name which will truncate its end */
63 lttng_ust_setustprocname();
64 ret
= lttng_pthread_getname_np(name
, TEST_NAME_PROPER_LEN
);
65 ok(strcmp(long_name_ust
, name
) == 0, "Compare the long UST thread name: %s == %s", long_name_ust
, name
);
This page took 0.031737 seconds and 5 git commands to generate.