This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add test for pthread_setname_np and pthread_getname_np.


On 02/04/2014 09:18 AM, Joseph S. Myers wrote:
> On Mon, 3 Feb 2014, Carlos O'Donell wrote:
> 
>> diff --git a/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c b/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
>> index 2aceba5..0235d37 100644
>> --- a/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
>> +++ b/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
>> @@ -99,6 +99,17 @@ do_test (int argc, char **argv)
>>    if (res == 0)
>>      {
>>        res = get_self_comm (gettid (), name_check, TASK_COMM_LEN);
>> +
>> +      /* On this first test we look for ENOENT to be returned from
>> +         get_self_comm to indicate that the kernel is older than
>> +         2.6.33 and doesn't contain comm within the proc structure.
>> +         In that case we skip the entire test.  */
>> +      if (res == ENOENT)
>> +       {
>> +         printf ("SKIP: The kernel does not have /proc/self/task/%%lu/comm.\n");
>> +         return 0;
>> +       }
> 
> I'd like it to be obvious that this can be removed when we require kernel 
> 2.6.33 or later (maybe in a couple of years' time).  Could you condition 
> this on __LINUX_KERNEL_VERSION < 0x020621, or (more cleanly) a 
> corresponding __ASSUME_PROC_PID_TASK_COMM defined in kernel-features.h for 
> __LINUX_KERNEL_VERSION >= 0x020621 (with an include of kernel-features.h 
> in this test, of course)?

Allan,

The Linux-specific test for pthread_setname_np and pthread_getname_np
fails on systems running the Linux kernel 2.6.32 or older. The fix
below makes us skip this test when the kernel is older than 2.6.33
(when /proc/self/task/%lu/comm was added, which is required by the test).

I'd like to check this in if you don't object to cleanup the testsuite
for results for Adhemerval who is testing on systems with older kernels.

Joseph,

Absolutely. That's a great idea.

Simulated testing by using invalid path and rebuilding with
arch_minimum_kernel set to 2.6.33.

Tested on x86-64 with no regressions.

OK to checkin?

/

2014-02-04  Carlos O'Donell  <carlos@rehdat.com>

	* sysdeps/unix/sysv/linux/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621]
	(__ASSUME_PROC_PID_TASK_COMM): Define.

nptl/

2014-02-04  Carlos O'Donell  <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/tst-setgetname.c (do_test): Skip the
	test if !__ASSUME_PROC_PID_TASK_COMM and get_self_comm returns
	ENOENT.

diff --git a/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c b/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
index 2aceba5..f5693e2 100644
--- a/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
+++ b/nptl/sysdeps/unix/sysv/linux/tst-setgetname.c
@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <kernel-features.h>
 
 /* New name of process.  */
 #define NEW_NAME "setname"
@@ -99,6 +100,19 @@ do_test (int argc, char **argv)
   if (res == 0)
     {
       res = get_self_comm (gettid (), name_check, TASK_COMM_LEN);
+
+#if !__ASSUME_PROC_PID_TASK_COMM
+      /* On this first test we look for ENOENT to be returned from
+         get_self_comm to indicate that the kernel is older than
+         2.6.33 and doesn't contain comm within the proc structure.
+         In that case we skip the entire test.  */
+      if (res == ENOENT)
+       {
+         printf ("SKIP: The kernel does not have /proc/self/task/%%lu/comm.\n");
+         return 0;
+       }
+#endif
+
       if (res == 0)
        {
          if (strncmp (name, name_check, strlen (BIG_NAME)) == 0)
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 3723535..d59531c 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -199,7 +199,10 @@
 
 /* Support for the recvmmsg syscall was added in 2.6.33.  */
 #if __LINUX_KERNEL_VERSION >= 0x020621
-# define __ASSUME_RECVMMSG     1
+# define __ASSUME_RECVMMSG             1
+/* Assume that /proc/self/task/$tid/comm and /proc/$pid/task/$tid/comm
+   exist.  */
+# define __ASSUME_PROC_PID_TASK_COMM   1
 #endif
 
 /* statfs fills in f_flags since 2.6.36.  */
---

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]