Hi,

I have noticed UNTESTED behavior with sched_setparam/26-1.c test case
under open_posix_testsuite.

Test needs to be executed as non-root user.
So I have changed user id from root to non-root user by adding
set_nonroot() function.
Now test case got PASSED.

I have attached patch and results before and after the patch.
please review the same.


Best regards,
Naresh Kamboju

/*********************************************************************************************/
Before Patch:
/*********************************************************************************************/
# ./26-1.test
Run this test case as a Regular User, but not ROOT
conformance/interfaces/sched_setparam/26-1.test:execution:UNTESTED
/*********************************************************************************************/
After Patch:
/*********************************************************************************************/
# ./26-1.test
Testing with user 'bin' (uid: 1)
Test PASSED
conformance/interfaces/sched_setparam/26-1.test:execution:PASSED
/*********************************************************************************************/

Signed-off-by: Naresh Kamboju < [email protected] >

diff -Naurb 
a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/26-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/26-1.c
--- 
a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/26-1.c   
    2005-06-03
22:03:02.000000000 +0530
+++ 
b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/26-1.c   
    2009-08-06
14:36:01.000000000 +0530
@@ -16,9 +16,39 @@
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
+#include <pwd.h>
 #include "posixtest.h"


+/** Set the euid of this process to a non-root uid */
+int set_nonroot()
+{
+       struct passwd *pw;
+       setpwent();
+       /* search for the first user which is non root */
+       while((pw = getpwent()) != NULL)
+               if(strcmp(pw->pw_name, "root"))
+                       break;
+       endpwent();
+       if(pw == NULL) {
+               printf("There is no other user than current and root.\n");
+               return 1;
+       }
+
+       if(seteuid(pw->pw_uid) != 0) {
+               if(errno == EPERM) {
+                       printf("You don't have permission to change your 
UID.\n");
+                       return 1;
+               }
+               perror("An error occurs when calling seteuid()");
+               return 1;
+       }
+       
+       printf("Testing with user '%s' (uid: %d)\n",
+              pw->pw_name, (int)geteuid());
+       return 0;
+}
+

 int main(){
        int result;
@@ -28,9 +58,11 @@
         /* and can only be accessed by root */
         /* This test should be run under standard user permissions */
         if (getuid() == 0) {
-                puts("Run this test case as a Regular User, but not ROOT");
+               if (set_nonroot() != 0) {
+                         printf("Cannot run this test as non-root user\n");    
                 return PTS_UNTESTED;
         }
+        }

        if(sched_getparam(0, &param) == -1) {
                perror("An error occurs when calling sched_getparam()");

Attachment: ltp-fix-sched_setparam_26-1.patch
Description: Binary data

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to