Adding Serial printouts and completing testcase for one table and two keys.
authorrtrimana <rtrimana@uci.edu>
Wed, 11 Apr 2018 23:01:44 +0000 (16:01 -0700)
committerrtrimana <rtrimana@uci.edu>
Wed, 11 Apr 2018 23:01:44 +0000 (16:01 -0700)
version2/src/C/Test.ino

index 408622caf5bdbca400bcc649afb4a3e0a0234e2a..62672148340f7c0ff31e05126cc07965c8cfb04b 100644 (file)
@@ -11,15 +11,20 @@ MyVector<TransactionStatus *> * transStatusList;
 Table *t1;
 
 void setup() {
-  Serial.begin();
+       // TODO: This test uses the Serial library
+       // Please install "screen" on your machine and run
+       // it on the serial port right after flashing the
+       // firmware onto the Particle board.
+       // e.g. sudo screen /dev/ttyACM0
+       Serial.begin();
        timer = TimingSingleton_getInstance();
        foundError = false;
        transStatusList = new MyVector<TransactionStatus *>();
        IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
-  IoTString * password = new IoTString("reallysecret");
+       IoTString * password = new IoTString("reallysecret");
        t1 = new Table(baseurl, password, 321, -1);
-  t1->initTable();                              
-
+       t1->initTable();                                 
+       Serial.println("Finished table init...");
        baseurl->releaseRef();
        password->releaseRef();
 
@@ -31,10 +36,11 @@ void setup() {
                sprintf(buffer, "b%d", i);
                IoTString *ib = new IoTString(buffer);
                t1->createNewKey(ia, 321);
-               t1->createNewKey(ib, 351);
+               t1->createNewKey(ib, 321);
                ia->releaseRef();
                ib->releaseRef();
        }
+       Serial.println("Finished key generation...");
 }
 
 
@@ -61,9 +67,16 @@ void loop() {
                transStatusList->add(t1->commitTransaction());
                iKeyB->releaseRef();
                iValueB->releaseRef();
+
+               Serial.println("Added new transaction: ");
+               Serial.print("a");
+               Serial.println(i);
+               Serial.print("b");
+               Serial.println(i);
        }
 
        t1->update();
+       Serial.println("Updated table...");
 
        for (int i = 0; i < NUMBER_OF_TESTS; i++) {
                char buffer[80];
@@ -79,12 +92,12 @@ void loop() {
                IoTString *testValB1 = t1->getCommitted(iKeyB);
 
                if ((testValA1 == NULL) || (testValA1->equals(iValueA) == false)) {
-               //                      printf("Key-Value t1 incorrect: keyA\n");
+                       Serial.println("Key-Value t1 incorrect: keyA");
                        foundError = true;
                }
 
                if ((testValB1 == NULL) || (testValB1->equals(iValueB) == false)) {
-               //                      printf("Key-Value t1 incorrect: keyB\n");
+                       Serial.println("Key-Value t1 incorrect: keyB");
                        foundError = true;
                }
 
@@ -100,16 +113,18 @@ void loop() {
                TransactionStatus * status = transStatusList->get(i);
                if (status->getStatus() != TransactionStatus_StatusCommitted) {
                        foundError = true;
-//                     printf("Status error\n");
+                       Serial.println("Status error");
                }
                delete status;
        }
 
        if (foundError) {
-//             printf("Found Errors...\n");
-       } else {
+               Serial.println("Found Errors...");
        }
 
        delete transStatusList;
        delete t1;
+       
+       Serial.println("Process done... now waiting...");
+       while(true) { }
 }