Hi Mathias,

On Tue, 2009-04-14 at 09:36 +0200, M. Koehrer wrote:
> Hi Manas,
> 
> thanks for your mail.
> I agree that you can use this tiny program to contribute it to LTP under the 
> GPL.

Thanks for this.

> I don't know if it helps you there as the issue can be reproduced only when 
> stopping the
> program via gdb. I assume that the LTP programs are running in a kind of 
> batch mode or
> is it possible to "simulate" a gdb debug session?

No. I think he just wants to test the Basic functionality of the
clock_nanosleep2() syscall, to see that calling the syscall under normal
circumstances does not fail. If it fails in future, means some
regression(s) introduced in the kernel.

> 
> Regards
> 
> Mathias
> ----- Original Nachricht ----
> Von:     Manas K Nayak <[email protected]>
> An:      "M. Koehrer" <[email protected]>
> Datum:   13.04.2009 14:27
> Betreff: [PATCH 02/03] Add clock_nanosleep2() syscall test to LTP [LKML 
> Subject: Issue with clock_nanosleep(), TIMER_ABSTIME and 
> CONFIG_CC_OPTIMIZE_FOR_SIZE not set]
> 
> > Hi Mathias,
> > 
> > >Hi all!
> > >I am using kernel 2.6.29.1 from kernel.org on a Debian 5.0 (Lenny) system
> > (Intel Core2Quad).
> > >GCC is 4.3.2
> > >I have not set CONFIG_CC_OPT_SIZE.
> > >
> > >When I use clock_nanosleep with TIMER_ABSTIME with gdb and stop the
> > execution by CTRL-C,
> > >I cannot continue the execution of my program when it interrupted the
> > clock_nanosleep call.
> > >
> > >When I set the kernel config parameter CONFIG_CC_OPT_SIZE everything is
> > fine.
> > >There seems to be an optimization issue that is related to the
> > clock_nanosleep system call.
> > >
> > >Some more remarks:
> > >When I use relative times (mode set to 0) everything works fine in both
> > cases.
> > >CONFIG_TICK_ONESHOT=y
> > >CONFIG_HIGH_RES_TIMERS=y
> > >
> > >
> > >Here is my tiny test program that demonstrates the behaviour:
> > >Let it run in gdb, interrupt it (CTRL-C) and try to continue "c".
> > >
> > >***************** BEGIN ************************
> > >#define _GNU_SOURCE
> > >#include <stdio.h>
> > >#include <time.h>
> > >#include <unistd.h>
> > >#include <sys/syscall.h>
> > >#include <linux/unistd.h>
> > >
> > >const clockid_t CLOCK_TO_USE=CLOCK_MONOTONIC;
> > >static int clock_nanosleep2(clockid_t clock_id, int flags, const struct
> > timespec *req,
> > >               struct timespec *rem)
> > >{
> > >   return syscall(__NR_clock_nanosleep, clock_id, flags, req, rem);
> > >}
> > >
> > >int main(void)
> > >{
> > >   int i;
> > >   struct timespec ts;
> > >   clock_gettime(CLOCK_TO_USE, &ts);
> > >
> > >   for (i=0; i<=1000; i++)
> > >   {
> > >       ts.tv_sec++;
> > >       clock_nanosleep2(CLOCK_TO_USE, TIMER_ABSTIME, &ts, NULL);
> > >       // clock_nanosleep(CLOCK_TO_USE, TIMER_ABSTIME, &ts, NULL);
> > >       printf("%i\n",i);
> > >   }
> > >
> > >   return 0;
> > >}
> > >
> > >/* Build with
> > >  gcc test_clock_nanosleep.c -g -Wall -lrt
> > >*/
> > >**************** END *******************
> > >
> > >Thanks for all feedback on that issue
> > 
> > I picked up this test porgram written by you from LKML, and has ported the
> > same to LTP under GPL. If you would agree, we can contribute this small
> > test to LTP. The below patch does that for you.
> > 
> > Original-Author: M. Koehrer <[email protected]>,
> > Ported-To-LTP-By: Manas K Nayak <[email protected]>,
> > ---
> > 
> > ---
> > ltp-full-20090331.orig/testcases/kernel/syscalls/clock_nanosleep2/clock_nano
> > sleep2_01.c 1970-01-01 05:30:00.000000000 +0530
> > +++
> > ltp-full-20090331/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep
> > 2_01.c      2009-04-13 16:50:18.000000000 +0530
> > @@ -0,0 +1,155 @@
> > +/**************************************************************************
> > ****/
> > +/* Copyright (c) M. Koehrer <[email protected]>, 2009               
> >   */
> > +/*                                                                         
> >   */
> > +/* LKML Reference: http://lkml.org/lkml/2009/4/9/89                        
> >   */
> > +/*                                                                         
> >   */
> > +/* This program is free software;  you can redistribute it and/or modify   
> >   */
> > +/* it under the terms of the GNU General Public License as published by    
> >   */
> > +/* the Free Software Foundation; either version 2 of the License, or       
> >   */
> > +/* (at your option) any later version.                                     
> >   */
> > +/*                                                                         
> >   */
> > +/* This program is distributed in the hope that it will be useful,         
> >   */
> > +/* but WITHOUT ANY WARRANTY;  without even the implied warranty of         
> >   */
> > +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See               
> >   */
> > +/* the GNU General Public License for more details.                        
> >   */
> > +/*                                                                         
> >   */
> > +/* You should have received a copy of the GNU General Public License       
> >   */
> > +/* along with this program;  if not, write to the Free Software            
> >   */
> > +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
> >   */
> > +/*                                                                         
> >   */
> > +/**************************************************************************
> > ****/
> > +/**************************************************************************
> > ****/
> > +/*                                                                         
> >   */
> > +/* File:        clock_nanosleep2_01.c                                      
> >   */
> > +/*                                                                         
> >   */
> > +/* Description: This tests the clock_nanosleep2-out() syscall              
> >   */
> > +/*                                                                         
> >   */
> > +/* Usage:  <for command-line>                                              
> >   */
> > +/* clock_nanosleep2_01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                
> >   */
> > +/*      where,  -c n : Run n copies concurrently.                          
> >   */
> > +/*              -e   : Turn on errno logging.                              
> >   */
> > +/*              -i n : Execute test n times.                               
> >   */
> > +/*              -I x : Execute test for x seconds.                         
> >   */
> > +/*              -P x : Pause for x seconds between iterations.             
> >   */
> > +/*              -t   : Turn on syscall timing.                             
> >   */
> > +/*                                                                         
> >   */
> > +/* Total Tests: 1                                                          
> >   */
> > +/*                                                                         
> >   */
> > +/* Test Name:   clock_nanosleep2_01                                        
> >   */
> > +/**************************************************************************
> > ****/
> > +#define _GNU_SOURCE
> > +#include <stdio.h>
> > +#include <time.h>
> > +#include <unistd.h>
> > +#include <sys/syscall.h>
> > +#include <linux/unistd.h>
> > +
> > +/* Harness Specific Include Files. */
> > +#include "test.h"
> > +#include "usctest.h"
> > +#include "linux_syscall_numbers.h"
> > +
> > +/* Extern Global Variables */
> > +extern int Tst_count;           /* counter for tst_xxx routines.        
> > */
> > +extern char *TESTDIR;           /* temporary dir created by tst_tmpdir()
> > */
> > +
> > +/* Global Variables */
> > +char *TCID = "clock_nanosleep2_01";  /* Test program identifier.*/
> > +int  testno;
> > +int  TST_TOTAL = 1;                   /* total number of tests in this
> > file.   */
> > +
> > +/* Extern Global Functions */
> > +/**************************************************************************
> > ****/
> > +/*                                                                         
> >   */
> > +/* Function:    cleanup                                                    
> >   */
> > +/*                                                                         
> >   */
> > +/* Description: Performs all one time clean up for this test on successful 
> >   */
> > +/*              completion,  premature exit or  failure. Closes all
> > temporary */
> > +/*              files, removes all temporary directories exits the test
> > with  */
> > +/*              appropriate return code by calling tst_exit() function.    
> >   */
> > +/*                                                                         
> >   */
> > +/* Input:       None.                                                      
> >   */
> > +/*                                                                         
> >   */
> > +/* Output:      None.                                                      
> >   */
> > +/*                                                                         
> >   */
> > +/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.
> >   */
> > +/*              On success - Exits calling tst_exit(). With '0' return
> > code.  */
> > +/*                                                                         
> >   */
> > +/**************************************************************************
> > ****/
> > +extern void cleanup() {
> > +        /* Remove tmp dir and all files in it */
> > +        TEST_CLEANUP;
> > +        tst_rmdir();
> > +
> > +        /* Exit with appropriate return code. */
> > +        tst_exit();
> > +}
> > +
> > +/* Local  Functions */
> > +/**************************************************************************
> > ****/
> > +/*                                                                         
> >   */
> > +/* Function:    setup                                                      
> >   */
> > +/*                                                                         
> >   */
> > +/* Description: Performs all one time setup for this test. This function is
> >   */
> > +/*              typically used to capture signals, create temporary dirs   
> >   */
> > +/*              and temporary files that may be used in the course of this 
> >   */
> > +/*              test.                                                      
> >   */
> > +/*                                                                         
> >   */
> > +/* Input:       None.                                                      
> >   */
> > +/*                                                                         
> >   */
> > +/* Output:      None.                                                      
> >   */
> > +/*                                                                         
> >   */
> > +/* Return:      On failure - Exits by calling cleanup().                   
> >   */
> > +/*              On success - returns 0.                                    
> >   */
> > +/*                                                                         
> >   */
> > +/**************************************************************************
> > ****/
> > +void setup() {
> > +        /* Capture signals if any */
> > +        /* Create temporary directories */
> > +        TEST_PAUSE;
> > +        tst_tmpdir();
> > +}
> > +
> > +
> > +const clockid_t CLOCK_TO_USE=CLOCK_MONOTONIC;
> > +static int clock_nanosleep2(clockid_t clock_id, int flags, const struct
> > timespec *req,struct timespec *rem)
> > +{
> > +   return syscall(__NR_clock_nanosleep, clock_id, flags, req, rem);
> > +}
> > +
> > +
> > +int main(int ac, char **av) {
> > +   int i;
> > +   int lc;                 /* loop counter */
> > +   char *msg;              /* message returned from parse_opts */
> > +   struct timespec ts;
> > +   
> > +        /* parse standard options */
> > +        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char
> > *)NULL){
> > +             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> > +             tst_exit();
> > +           }
> > +
> > +        setup();
> > +
> > +        /* Check looping state if -i option given */
> > +        for (lc = 0; TEST_LOOPING(lc); ++lc) {
> > +                Tst_count = 0;
> > +                for (testno = 0; testno < TST_TOTAL; ++testno) {
> > +                   TEST(clock_gettime(CLOCK_TO_USE, &ts));
> > +                   for (i=0; i<=50; i++){
> > +                           ts.tv_sec++;
> > +                           TEST(clock_nanosleep2(CLOCK_TO_USE, 
> > TIMER_ABSTIME, &ts, NULL));
> > +                                if (TEST_ERRNO) {
> > +                                    tst_resm(TFAIL, "%s failed - errno = %d
> > : %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO));

This statement will do the job.

Regards--
Subrata

> > +                                    cleanup();
> > +                                    tst_exit();
> > +                                }
> > +                           tst_resm(TINFO,"Iteration = %i",i);
> > +                   }
> > +                        tst_resm(TPASS, "clock_nanosleep2() passed");
> > +           }
> > +        }  
> > +        tst_exit();
> > +}
> > +
> > ---
> > ltp-full-20090331.orig/testcases/kernel/syscalls/clock_nanosleep2/Makefile
> > 1970-01-01 05:30:00.000000000 +0530
> > +++ ltp-full-20090331/testcases/kernel/syscalls/clock_nanosleep2/Makefile
> > 2009-04-13 16:37:08.000000000 +0530
> > @@ -0,0 +1,31 @@
> > +#
> > +#  Copyright (c) International Business Machines  Corp., 2009
> > +#
> > +#  This program is free software;  you can redistribute it and/or modify
> > +#  it under the terms of the GNU General Public License as published by
> > +#  the Free Software Foundation; either version 2 of the License, or
> > +#  (at your option) any later version.
> > +#
> > +#  This program is distributed in the hope that it will be useful,
> > +#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
> > +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> > +#  the GNU General Public License for more details.
> > +#
> > +#  You should have received a copy of the GNU General Public License
> > +#  along with this program;  if not, write to the Free Software
> > +#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
> > USA
> > +#
> > +
> > +CFLAGS += -I../../../../include -Wall
> > +LDLIBS += -L../../../../lib -lltp -lrt
> > +
> > +SRCS    = $(wildcard *.c)
> > +TARGETS = $(patsubst %.c,%,$(SRCS))
> > +
> > +all: $(TARGETS)
> > +
> > +install:
> > +   @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
> > +
> > +clean:
> > +   rm -f $(TARGETS)
> > --- ltp-full-20090331.orig/runtest/syscalls 2009-04-13 16:14:07.000000000
> > +0530
> > +++ ltp-full-20090331/runtest/syscalls      2009-04-13 17:02:05.000000000 
> > +0530
> > @@ -67,6 +67,7 @@ chroot02 chroot02
> >  chroot03 chroot03
> >  chroot04 chroot04
> >  
> > +clock_nanosleep2_01 clock_nanosleep2_01
> >  
> >  clone01 clone01
> >  clone02 clone02
> > 
> > ---
> > Regards--
> > Manas
> > 
> > 
> 


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to