Instead of using a custom python script, I have decided to use a C program for the purpose. In my earlier strategy, I was trying to get resource usage statistics of the process, under consideration, by means of using getrusage() , record it in a file and exit the program immediately. The problem with this strategy is that by the time I write to a file, the resource usage statistics gets updated and this doesn't get reflected in the files.
In my renewed strategy , instead of relying on any system calls directly, I have decided to rely upon the *stat* (stat ,status and statm) *files in the directory */proc/[pid].* The idea is to copy all the required files under /proc/[pid] before the process exists.Here is the detailed steps. 1.Parent forks a child process. 2.Child process goes to sleep thus letting the parent execute first. 3.Parent starts execution. 4.Child wakes up,pauses the parent using SIGSTOP signal. 5.Child takes the backup of all the required files from /proc/[pid]. 6.Child KILLS parent. The Parent process will be run by the time command. We can cross check the output of time with that of the stat* files that has been backed up. You may check out [1] for a demo program. [1] http://pastebin.com/9wCzewSk On Fri, Jan 18, 2013 at 2:47 PM, Poornima Nayak <[email protected]>wrote: > Hi Lucas > > We had discussed about it before whether LTP or Autotest. We decided > Autotest because these tests will be written in Python and LTP does not > support any reusable functions in Python. > I know these many tests will create lot many test wrappers, so what we > have decided is, we will have directory like crontab, time and test suits > under linux-tools as below > client/tests/linux-tools/time > client/tests/linux-tools/crontab > > I will explore this in this weekend if this proposed way will work in > autotest or not. > > Regards > Poornima > > > *Lucas Meneghel Rodrigues <[email protected]>* > > 01/14/2013 11:36 PM > To > Paul Davies C <[email protected]>, > cc > Athira Rajeev/India/IBM@IBMIN, Poornima Nayak/India/IBM@IBMIN, Autotest > Mailing list <[email protected]>, Rajeev S <[email protected] > > > Subject > Re: [Autotest] [RFC] Testing time > > > > > I stepped for a moment and started to think about these wrappers > testing smaller, individual user space tools, such as crontab, time, > among others. It seems to me that such tests belong to a larger linux > test suite, such as LTP. Otherwise we'll end up with a large amount of > wrappers for tiny tests, which probably is not the granularity we're > aiming for. > > So Poornima, Paul, Rajeev and the other folks - did you guys consider > to contribute such tests to LTP, for example? > > On Sat, Jan 12, 2013 at 12:48 PM, Paul Davies C <[email protected]> > wrote: > > Description: > > > > > > time runs the program COMMAND with any given arguments . When COMMAND > > finishes, time displays information about resources used by COMMAND (on > the > > standard error output, by default). If COMMAND exits with non-zero > status, > > time displays a warning message and the exit status. time can be used to > > track the real,system and user time of COMMAND. > > > > > > Dependent Binaries: > > > > /usr/bin/time > > > > > > Approach: > > > > > > Create a custom python script which will be given as input to time > package. > > > > This custom python script will record its own resource usage statistics > in > > temporary file. > > > > The time package is also made to store the resource usage statistics > using > > its switches of the custom python script in another file. > > > > The values in the above mentioned files are compared to verify the > correct > > working of time. > > > > A custom shell script is also made so that the real time given by the > time > > can be confirmed. > > > > This custom shell script has nothing except sleep command. > > > > Switches to be tested : > > > > time -p (lists real ,user and system time0 > > > > time -v(Outputs an elaborated resource usage statistics) > > > > Test: > > > > time -p: > > > > Run time -p with custom shell script. > > > > Confirm the "real time" output with that of argument to sleep in custom > > shell script. > > > > time -v: > > > > Run time -v with custom python script. > > > > Compare the values in two output files generated by the time and the > custom > > python script. > > > > Clean Up: > > > > Clean all the scripts/output files generated by the test > > > > -- > > Regards, > > Paul Davies C > > vivafoss.blogspot.com > > > > _______________________________________________ > > Autotest-kernel mailing list > > [email protected] > > https://www.redhat.com/mailman/listinfo/autotest-kernel > > > > -- > Lucas > > > -- *Regards,* *Paul Davies C* vivafoss.blogspot.com
_______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
