Fixed tko.proto to have inner message 'classes' to serialize correctly. Fixed 
Status setup in job_serializer_unittest.
OK to submit to non-main branch.

Signed-off-by: Darren Kuo <[email protected]>

--- autotest/tko/job_serializer.py      2010-06-04 10:21:16.000000000 -0700
+++ autotest/tko/job_serializer.py      2010-06-09 14:53:04.000000000 -0700
@@ -78,7 +78,7 @@
         be returned.
         """
 
-        job_pb = tko_pb2.job()
+        job_pb = tko_pb2.Job()
 
         binary = open(infile, 'r')
         try:
@@ -110,7 +110,7 @@
         binary of the serialized object.
         """
 
-        job_pb = tko_pb2.job()
+        job_pb = tko_pb2.Job()
         self.set_pb_job(the_job, job_pb)
 
         out = open(binaryfilename, 'wb')
--- autotest/tko/job_serializer_unittest.py     2010-06-04 10:21:16.000000000 
-0700
+++ autotest/tko/job_serializer_unittest.py     2010-06-09 14:53:04.000000000 
-0700
@@ -32,7 +32,7 @@
         tko_kernel = models.kernel('tubes', tko_patches, '1234567')
         tko_time = datetime.now()
 
-        tko_job = models.job('/tmp/', 'root', 'test', 'My Computer',
+        tko_job = models.job('/tmp/', 'darrenkuo', 'test', 'My Computer',
                              tko_time, tko_time, tko_time, 'root',
                              'www', 'No one', tko_time, {'1+1':2})
 
@@ -41,7 +41,7 @@
 
         tko_labels = ['unittest', 'dummy test', 'autotest']
 
-        tko_test = models.test('/tmp/', 'mocktest', 'PASS', 'N/A',
+        tko_test = models.test('/tmp/', 'mocktest', 'Completed', 'N/A',
                                tko_kernel, 'My Computer', tko_time,
                                tko_time, [tko_iteration,
                                tko_iteration, tko_iteration],
@@ -50,7 +50,7 @@
         self.tko_job = tko_job
         self.tko_job.tests = [tko_test, tko_test, tko_test]
 
-        self.pb_job = tko_pb2.job()
+        self.pb_job = tko_pb2.Job()
         js = job_serializer.JobSerializer()
         js.set_pb_job(self.tko_job, self.pb_job)
 
@@ -237,7 +237,7 @@
 
             binary = open(out_binary.name, 'rb')
             try:
-                self.pb_job = tko_pb2.job()
+                self.pb_job = tko_pb2.Job()
                 self.pb_job.ParseFromString(binary.read())
             finally:
                 binary.close()
@@ -258,7 +258,9 @@
         try:
             temp_binary.write(self.pb_job.SerializeToString())
             temp_binary.flush()
-
+            f = open('qa-job.serialize', 'wb')
+            f.write(self.pb_job.SerializeToString())
+            f.close()
             js = job_serializer.JobSerializer()
             self.from_pb_job = js.deserialize_from_binary(temp_binary.name)
         finally:
--- autotest/tko/tko.proto      2010-06-04 10:21:16.000000000 -0700
+++ autotest/tko/tko.proto      2010-06-09 14:53:04.000000000 -0700
@@ -1,11 +1,45 @@
-message keyval {
-    required string name = 1;
-    required string value = 2;
-}
+syntax = "proto2";
+
+message Job {
+    message KeyVal {
+        required string name = 1;
+        required string value = 2;
+    }
+
+    message Kernel {
+        required string base = 1;
+        repeated Patch patches = 2;
+        required string kernel_hash = 3;
+    }
+
+    message Patch {
+        required string spec = 1;
+        required string reference = 2;
+        required int64 hash = 3;
+    }
+
+    message Iteration {
+        required int64 index = 1;
+        repeated KeyVal attr_keyval = 2;
+        repeated KeyVal perf_keyval = 3;
+    }
+
+    message Test {
+        required string subdir = 1;
+        required string testname = 2;
+        required string status = 3;
+        required string reason = 4;
+        required Kernel kernel = 5;
+        required string machine = 6;
+        required int64 started_time = 7;
+        required int64 finished_time = 8;
+        repeated Iteration iterations = 9;
+        repeated KeyVal attributes = 10;
+        repeated string labels = 11;
+    }
 
-message job {
     required string dir = 1;
-    repeated test tests = 2;
+    repeated Test tests = 2;
     required string user = 3;
     required string label = 4;
     required string machine = 5;
@@ -16,37 +50,5 @@
     required string machine_group = 10;
     required string aborted_by = 11;
     required int64 aborted_on = 12;
-    repeated keyval keyval_dict = 13;
-}
-
-message kernel {
-    required string base = 1;
-    repeated patch patches = 2;
-    required string kernel_hash = 3;
-}
-
-message patch {
-    required string spec = 1;
-    required string reference = 2;
-    required int64 hash = 3;
-}
-
-message iteration {
-    required int64 index = 1;
-    repeated keyval attr_keyval = 2;
-    repeated keyval perf_keyval = 3;
-}
-
-message test {
-    required string subdir = 1;
-    required string testname = 2;
-    required string status = 3;
-    required string reason = 4;
-    required kernel kernel = 5;
-    required string machine = 6;
-    required int64 started_time = 7;
-    required int64 finished_time = 8;
-    repeated iteration iterations = 9;
-    repeated keyval attributes = 10;
-    repeated string labels = 11;
+    repeated KeyVal keyval_dict = 13;
 }
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to