From cd6e43f37856f7fe6b60e0e2ae45f864a4bd6d64 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 22 Mar 2009 22:21:21 -0400 Subject: Test driver now gets as far as releasing the task set. Appears correct, but I need to control output from the st_trace in the future. --- test_driver/test.py | 89 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 8 deletions(-) (limited to 'test_driver') diff --git a/test_driver/test.py b/test_driver/test.py index 032b424..87038a0 100755 --- a/test_driver/test.py +++ b/test_driver/test.py @@ -7,8 +7,8 @@ #liblitmus directory (You need to put the compiled liblitmus here) liblitmus_dir = '/root/liblitmus/' -#ft_trace directory (You need to but the compiled ft_tools here) -ft_trace_dir = '/root/ft_trace/' +#ft_tools directory (You need to but the compiled ft_tools here) +ft_tools_dir = '/root/ft_tools/' #device files directory (This script will set up the device files here) device_dir = '/root/device_files/' @@ -20,9 +20,16 @@ trace_dir = '/root/traces/' #options listed in /proc/litmus/plugins policy = 'GSN-EDF' +#desired test case +test_case_file = 'sample_test_case' + +#name of traces +trace_name = 'driver' + #Additional instructions: # -Make sure you've chmod +x'd the make_devices file and kept it in the same # dir as test.py +# -Make sure you've set up a test case ########### # Imports # @@ -30,7 +37,8 @@ policy = 'GSN-EDF' import subprocess import os - +import time +exec('from ' + test_case_file + ' import test_case') ################# # Run the tests # @@ -42,16 +50,81 @@ def main(): test_dir = os.getcwd() #Set scheduling policy - subprocess.Popen('echo ' + policy + ' > ' + '/proc/litmus/active_plugin', - shell=True) - + print("Setting scheduling policy... ",end='') + ret = subprocess.getstatusoutput( + 'echo ' + policy + ' > ' + '/proc/litmus/active_plugin') + if ret[0] == 0: + print("[SUCCESS]") + else: + print("[FAILURE], error was:") + print(str(ret[0]) + ': ' + ret[1]) + exit() + + #Check for execute permission on the make_devices script + print("Checking for permission to run make_devices... ",end='') + if not os.access('./make_devices',os.X_OK): + print("\nAttempting to chmod +x make_devices... ",end='') + ret = subprocess.getstatusoutput('chmod +x ./make_devices') + if ret[0]!=1: + print("[FAILURE], error was:") + print(str(ret[0]) + ': ' + ret[1]) + exit() + print("[SUCCESS]") + #Setup the device files for the traces - subprocess.Popen('chmod +x make_devices',shell=True) + print("Creating device files. OK if they already exist.") subprocess.Popen(test_dir + '/make_devices',cwd=device_dir) + time.sleep(1) #Set up environment variables needed for st_trace script - os.putenv('FTCAT', ft_trace_dir + 'ftcat') + print("Setting up environment variables... ",end='') + os.putenv('FTCAT', ft_tools_dir + 'ftcat') os.putenv('FTDEV',device_dir + 'sched_trace') + print("[SUCCESS]") + + #See if we can access and run st_trace + print("Checking for permission to run st_trace... ",end='') + if not os.access(ft_tools_dir + 'st_trace',os.X_OK): + print("\nAttempting to chmod +x st_trace... ",end='') + ret = subprocess.getstatusoutput('chmod +x ' + + ft_tools_dir + 'st_trace') + if ret[0]!=1: + print("[FAILURE], error was:") + print(str(ret[0]) + ': ' + ret[1]) + exit() + print("[SUCCESS]") + + #Start sched_trace + print("Starting st_trace trace recorder... ",end='') + st_trace = subprocess.Popen([ft_tools_dir + 'st_trace',trace_name], + cwd=trace_dir) + print("[SUCCESS]") + + #We will get an error there, if the test.py program terminates. + #time.sleep(7) + + #Start tasks in test_case + print("Launching tasks... ",end='') + for task in test_case: + subprocess.Popen([task[0],'-w',str(task[1]),str(task[2]),str(task[3])]) + print("[SUCCESS]") + + #Wait for tasks to suspend themselves + print("Waiting for tasks to suspend... ",end='') + time.sleep(3) + print("[SUCCESS]") + + #Release the tasks + print("Releasing the tasks... ",end='') + ret = subprocess.getstatusoutput(liblitmus_dir + 'release_ts') + if ret[0] != 0: + print("[FAILURE], error was:") + print(str(ret[0]) + ': ' + ret[1]) + exit() + print("[SUCCESS]") + + #Wait for the tasks to complete. I still need to implement this. + #Current steps... #Run st_trace (must tell it location of sched_trace device files exactly) -- cgit v1.2.2