diff options
| author | root <root@mollison.localdomain> | 2009-03-22 22:21:21 -0400 |
|---|---|---|
| committer | root <root@mollison.localdomain> | 2009-03-22 22:21:21 -0400 |
| commit | cd6e43f37856f7fe6b60e0e2ae45f864a4bd6d64 (patch) | |
| tree | 5abaf81d8953d71e4fa82ad96be8f93fe2d493a4 | |
| parent | fcbfba47e8c9e1596cf5e6d061408f99ea6618d7 (diff) | |
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.
| -rwxr-xr-x | test_driver/test.py | 89 |
1 files changed, 81 insertions, 8 deletions
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 @@ | |||
| 7 | #liblitmus directory (You need to put the compiled liblitmus here) | 7 | #liblitmus directory (You need to put the compiled liblitmus here) |
| 8 | liblitmus_dir = '/root/liblitmus/' | 8 | liblitmus_dir = '/root/liblitmus/' |
| 9 | 9 | ||
| 10 | #ft_trace directory (You need to but the compiled ft_tools here) | 10 | #ft_tools directory (You need to but the compiled ft_tools here) |
| 11 | ft_trace_dir = '/root/ft_trace/' | 11 | ft_tools_dir = '/root/ft_tools/' |
| 12 | 12 | ||
| 13 | #device files directory (This script will set up the device files here) | 13 | #device files directory (This script will set up the device files here) |
| 14 | device_dir = '/root/device_files/' | 14 | device_dir = '/root/device_files/' |
| @@ -20,9 +20,16 @@ trace_dir = '/root/traces/' | |||
| 20 | #options listed in /proc/litmus/plugins | 20 | #options listed in /proc/litmus/plugins |
| 21 | policy = 'GSN-EDF' | 21 | policy = 'GSN-EDF' |
| 22 | 22 | ||
| 23 | #desired test case | ||
| 24 | test_case_file = 'sample_test_case' | ||
| 25 | |||
| 26 | #name of traces | ||
| 27 | trace_name = 'driver' | ||
| 28 | |||
| 23 | #Additional instructions: | 29 | #Additional instructions: |
| 24 | # -Make sure you've chmod +x'd the make_devices file and kept it in the same | 30 | # -Make sure you've chmod +x'd the make_devices file and kept it in the same |
| 25 | # dir as test.py | 31 | # dir as test.py |
| 32 | # -Make sure you've set up a test case | ||
| 26 | 33 | ||
| 27 | ########### | 34 | ########### |
| 28 | # Imports # | 35 | # Imports # |
| @@ -30,7 +37,8 @@ policy = 'GSN-EDF' | |||
| 30 | 37 | ||
| 31 | import subprocess | 38 | import subprocess |
| 32 | import os | 39 | import os |
| 33 | 40 | import time | |
| 41 | exec('from ' + test_case_file + ' import test_case') | ||
| 34 | 42 | ||
| 35 | ################# | 43 | ################# |
| 36 | # Run the tests # | 44 | # Run the tests # |
| @@ -42,16 +50,81 @@ def main(): | |||
| 42 | test_dir = os.getcwd() | 50 | test_dir = os.getcwd() |
| 43 | 51 | ||
| 44 | #Set scheduling policy | 52 | #Set scheduling policy |
| 45 | subprocess.Popen('echo ' + policy + ' > ' + '/proc/litmus/active_plugin', | 53 | print("Setting scheduling policy... ",end='') |
| 46 | shell=True) | 54 | ret = subprocess.getstatusoutput( |
| 47 | 55 | 'echo ' + policy + ' > ' + '/proc/litmus/active_plugin') | |
| 56 | if ret[0] == 0: | ||
| 57 | print("[SUCCESS]") | ||
| 58 | else: | ||
| 59 | print("[FAILURE], error was:") | ||
| 60 | print(str(ret[0]) + ': ' + ret[1]) | ||
| 61 | exit() | ||
| 62 | |||
| 63 | #Check for execute permission on the make_devices script | ||
| 64 | print("Checking for permission to run make_devices... ",end='') | ||
| 65 | if not os.access('./make_devices',os.X_OK): | ||
| 66 | print("\nAttempting to chmod +x make_devices... ",end='') | ||
| 67 | ret = subprocess.getstatusoutput('chmod +x ./make_devices') | ||
| 68 | if ret[0]!=1: | ||
| 69 | print("[FAILURE], error was:") | ||
| 70 | print(str(ret[0]) + ': ' + ret[1]) | ||
| 71 | exit() | ||
| 72 | print("[SUCCESS]") | ||
| 73 | |||
| 48 | #Setup the device files for the traces | 74 | #Setup the device files for the traces |
| 49 | subprocess.Popen('chmod +x make_devices',shell=True) | 75 | print("Creating device files. OK if they already exist.") |
| 50 | subprocess.Popen(test_dir + '/make_devices',cwd=device_dir) | 76 | subprocess.Popen(test_dir + '/make_devices',cwd=device_dir) |
| 77 | time.sleep(1) | ||
| 51 | 78 | ||
| 52 | #Set up environment variables needed for st_trace script | 79 | #Set up environment variables needed for st_trace script |
| 53 | os.putenv('FTCAT', ft_trace_dir + 'ftcat') | 80 | print("Setting up environment variables... ",end='') |
| 81 | os.putenv('FTCAT', ft_tools_dir + 'ftcat') | ||
| 54 | os.putenv('FTDEV',device_dir + 'sched_trace') | 82 | os.putenv('FTDEV',device_dir + 'sched_trace') |
| 83 | print("[SUCCESS]") | ||
| 84 | |||
| 85 | #See if we can access and run st_trace | ||
| 86 | print("Checking for permission to run st_trace... ",end='') | ||
| 87 | if not os.access(ft_tools_dir + 'st_trace',os.X_OK): | ||
| 88 | print("\nAttempting to chmod +x st_trace... ",end='') | ||
| 89 | ret = subprocess.getstatusoutput('chmod +x ' + | ||
| 90 | ft_tools_dir + 'st_trace') | ||
| 91 | if ret[0]!=1: | ||
| 92 | print("[FAILURE], error was:") | ||
| 93 | print(str(ret[0]) + ': ' + ret[1]) | ||
| 94 | exit() | ||
| 95 | print("[SUCCESS]") | ||
| 96 | |||
| 97 | #Start sched_trace | ||
| 98 | print("Starting st_trace trace recorder... ",end='') | ||
| 99 | st_trace = subprocess.Popen([ft_tools_dir + 'st_trace',trace_name], | ||
| 100 | cwd=trace_dir) | ||
| 101 | print("[SUCCESS]") | ||
| 102 | |||
| 103 | #We will get an error there, if the test.py program terminates. | ||
| 104 | #time.sleep(7) | ||
| 105 | |||
| 106 | #Start tasks in test_case | ||
| 107 | print("Launching tasks... ",end='') | ||
| 108 | for task in test_case: | ||
| 109 | subprocess.Popen([task[0],'-w',str(task[1]),str(task[2]),str(task[3])]) | ||
| 110 | print("[SUCCESS]") | ||
| 111 | |||
| 112 | #Wait for tasks to suspend themselves | ||
| 113 | print("Waiting for tasks to suspend... ",end='') | ||
| 114 | time.sleep(3) | ||
| 115 | print("[SUCCESS]") | ||
| 116 | |||
| 117 | #Release the tasks | ||
| 118 | print("Releasing the tasks... ",end='') | ||
| 119 | ret = subprocess.getstatusoutput(liblitmus_dir + 'release_ts') | ||
| 120 | if ret[0] != 0: | ||
| 121 | print("[FAILURE], error was:") | ||
| 122 | print(str(ret[0]) + ': ' + ret[1]) | ||
| 123 | exit() | ||
| 124 | print("[SUCCESS]") | ||
| 125 | |||
| 126 | #Wait for the tasks to complete. I still need to implement this. | ||
| 127 | |||
| 55 | 128 | ||
| 56 | #Current steps... | 129 | #Current steps... |
| 57 | #Run st_trace (must tell it location of sched_trace device files exactly) | 130 | #Run st_trace (must tell it location of sched_trace device files exactly) |
