Hi,

I have noticed sched_setscheduler/17-6.c test case as UNTESTED.

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

/************************************************************/
 Results:
/************************************************************/
Before patch:
conformance/interfaces/sched_setscheduler/17-6.test:execution:UNTESTED

After patch:
conformance/interfaces/sched_setscheduler/17-6.test:execution:PASS
/*************************************************************/


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


diff -Naurb 
a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/17-6.c
b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/17-6.c
--- 
a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/17-6.c
   2005-06-03
22:03:12.000000000 +0530
+++ 
b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/17-6.c
   2009-08-18
21:03:50.000000000 +0530
@@ -24,10 +24,42 @@
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
+#include <pwd.h>
+#include <string.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 max_priority, old_priority, old_policy, new_policy, policy;
         struct sched_param param;
@@ -36,9 +68,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(getpid(), &param) == -1) {
                perror("An error occurs when calling sched_getparam()");

Attachment: ltp-fix-sched_setscheduler_17-6.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