Merge pull request #36 from sinkap/bart_testing

Bart testing
diff --git a/tests/test_common_utils.py b/tests/test_common_utils.py
index 4f72325..ff6456a 100644
--- a/tests/test_common_utils.py
+++ b/tests/test_common_utils.py
@@ -1,3 +1,18 @@
+#    Copyright 2015-2015 ARM Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
 from bart.common import Utils
 import unittest
 import pandas as pd
diff --git a/tests/trace.raw.txt b/tests/trace.raw.txt
new file mode 100644
index 0000000..f66d55b
--- /dev/null
+++ b/tests/trace.raw.txt
@@ -0,0 +1,7 @@
+version = 6
+CPU 3 is empty
+CPU 4 is empty
+cpus=6
+              ls-4734  [002] 106439.675591: sched_switch:          prev_comm=trace-cmd prev_pid=4734 prev_prio=120 prev_state=1024 next_comm=migration/2 next_pid=18 next_prio=0
+     migration/2-18    [002] 106439.675613: sched_switch:          prev_comm=migration/2 prev_pid=18 prev_prio=0 prev_state=1 next_comm=trace-cmd next_pid=4732 next_prio=120
+       trace-cmd-4730  [001] 106439.675718: sched_switch:          prev_comm=trace-cmd prev_pid=4730 prev_prio=120 prev_state=1 next_comm=trace-cmd next_pid=4729 next_prio=120
diff --git a/tests/trace.txt b/tests/trace.txt
new file mode 100644
index 0000000..4fbf4c9
--- /dev/null
+++ b/tests/trace.txt
@@ -0,0 +1,7 @@
+version = 6
+CPU 3 is empty
+CPU 4 is empty
+cpus=6
+              ls-4734  [002] 106439.675591: sched_switch:         trace-cmd:4734 [120] R ==> migration/2:18 [0]
+     migration/2-18    [002] 106439.675613: sched_switch:         migration/2:18 [0] S ==> trace-cmd:4732 [120]
+       trace-cmd-4731  [001] 106439.675698: sched_switch:         trace-cmd:4731 [120] S ==> trace-cmd:4730 [120]
diff --git a/tests/utils_tests.py b/tests/utils_tests.py
new file mode 100644
index 0000000..63a050e
--- /dev/null
+++ b/tests/utils_tests.py
@@ -0,0 +1,56 @@
+#    Copyright 2015-2015 ARM Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+import unittest
+import os
+import shutil
+import subprocess
+import tempfile
+
+TESTS_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
+
+
+class SetupDirectory(unittest.TestCase):
+
+    def __init__(self, files_to_copy, *args, **kwargs):
+        self.files_to_copy = files_to_copy
+        super(SetupDirectory, self).__init__(*args, **kwargs)
+
+    def setUp(self):
+        self.previous_dir = os.getcwd()
+
+        self.out_dir = tempfile.mkdtemp()
+        os.chdir(self.out_dir)
+
+        for src_fname, dst_fname in self.files_to_copy:
+            src_fname = os.path.join(TESTS_DIRECTORY, src_fname)
+            shutil.copy(src_fname, os.path.join(self.out_dir, dst_fname))
+
+    def tearDown(self):
+        os.chdir(self.previous_dir)
+        shutil.rmtree(self.out_dir)
+
+
+class TestBART(SetupDirectory):
+
+    def __init__(self, *args, **kwargs):
+        super(TestBART, self).__init__(
+            [
+                ("./trace.txt", "trace.txt"),
+                ("./trace.raw.txt", "trace.raw.txt")
+            ],
+            *args,
+            **kwargs)