]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Move wvtest tests to the previous place
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 20 Jun 2010 09:49:51 +0000 (11:49 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 20 Jun 2010 09:49:51 +0000 (11:49 +0200)
frsh_api/tests/Makefile.omk
frsh_api/tests/negotiation.c [deleted file]
frsh_api/tests/negotiation.cc [new file with mode: 0644]
frsh_api/tests/negotiation.sh [new file with mode: 0755]
frsh_api/tests/wvtest.sh [new symlink]

index d4919863fa181d236f776ae84659125feec69b06..7b6a9c57f96b5e8cfafb3176949ecec77d3407bd 100644 (file)
@@ -1,6 +1,9 @@
+CFLAGS += -DWVTEST_CONFIGURED
 
+wvtest_SCRIPTS += negotiation.sh
 test_PROGRAMS += negotiation
-negotiation_SOURCES = negotiation.c
+negotiation_SOURCES = negotiation.cc
+negotiation_LIBS = wvtest
 
 test_PROGRAMS += spare_capacity
 spare_capacity_SOURCES = spare_capacity.c
diff --git a/frsh_api/tests/negotiation.c b/frsh_api/tests/negotiation.c
deleted file mode 100644 (file)
index aaae86e..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <frsh.h>
-#include <error.h>
-#include <res_dummy.h>
-#include <getopt.h>
-#include <ul_logreg.h>
-
-#define N 3
-
-int b[N] = { 10, 20, 30 };
-
-static struct option long_opts[] = {
-    { "loglevel", 1, 0, 'l' },
-    { 0, 0, 0, 0}
-};
-
-static void
-usage(void)
-{
-       printf("usage: negotiation [ options ]\n");
-       printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
-}
-
-
-
-int main(int argc, char *argv[])
-{
-       int ret;
-       frsh_contract_t contract[N];
-       frsh_vres_id_t vres[N];
-       frsh_rel_time_t budget, period, deadline;
-       int i;
-       char opt;
-
-       while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
-               switch (opt) {
-                       case 'l':
-                               ul_log_domain_arg2levels(optarg);
-                               break;
-                       case 'h':
-                       /*default:*/
-                               usage();
-                               exit(opt == 'h' ? 0 : 1);
-               }
-       }
-
-       ret = frsh_init();
-       if (ret) PERROR_AND_EXIT(ret, "frsh_init");
-
-       /* Negotiate N contracts */
-       for (i=0; i<N; i++) {
-               ret = frsh_contract_init(&contract[i]);
-               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_init");
-
-               ret = frsh_contract_set_resource_and_label(
-                       &contract[i],
-                       DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID,
-                       NULL);
-               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_resource_and_label");
-
-               budget = fosa_msec_to_rel_time(b[i]);
-               period = fosa_msec_to_rel_time(100);
-               deadline = fosa_msec_to_rel_time(50);
-               ret = frsh_contract_set_basic_params(&contract[i],
-                                                    &budget,
-                                                    &period,
-                                                    FRSH_WT_BOUNDED,
-                                                    FRSH_CT_REGULAR);
-               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params");
-               
-               ret = frsh_contract_set_timing_reqs(&contract[i],
-                                                   false, &deadline);
-               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_timing_reqs");
-               
-               ret = frsh_contract_negotiate(&contract[i], &vres[i]);
-               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_negotiate");
-       }
-       for (i=0; i<N; i++) {
-               budget = fosa_msec_to_rel_time(2*b[i]);
-               period = fosa_msec_to_rel_time(110);
-               ret = frsh_contract_set_basic_params(&contract[i],
-                                                    &budget,
-                                                    &period,
-                                                    FRSH_WT_BOUNDED,
-                                                    FRSH_CT_REGULAR);
-               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_set_basic_params reneg");
-
-               ret = frsh_contract_renegotiate_sync(&contract[i], vres[i]);
-               
-       }
-
-       /* Cancel N contracts */
-       for (i=0; i<N; i++) {
-               ret = frsh_contract_cancel(vres[i]);
-               if (ret) PERROR_AND_EXIT(ret, "frsh_contract_cancel");
-       }
-       return 0;
-}
diff --git a/frsh_api/tests/negotiation.cc b/frsh_api/tests/negotiation.cc
new file mode 100644 (file)
index 0000000..d4ce749
--- /dev/null
@@ -0,0 +1,108 @@
+#include <frsh.h>
+#include <error.h>
+#include <res_dummy.h>
+#include <getopt.h>
+#include <ul_logreg.h>
+#include <wvtest.h>
+
+#define N 3
+
+int b[N] = { 10, 20, 30 };
+
+// TODO: Allow specifying loglevel in evironment
+
+// static struct option long_opts[] = {
+//     { "loglevel", 1, 0, 'l' },
+//     { 0, 0, 0, 0}
+// };
+
+// static void
+// usage(void)
+// {
+//     printf("usage: negotiation [ options ]\n");
+//     printf("  -l, --loglevel <number>|<domain>=<number>,...\n");
+// }
+
+int ret;
+frsh_contract_t contract[N];
+frsh_vres_id_t vres[N];
+frsh_rel_time_t budget, period, deadline;
+int i;
+
+WVTEST_MAIN("basic negotiation")
+{
+//     char opt;
+
+//     while ((opt = getopt_long(argc, argv, "l:", &long_opts[0], NULL)) != EOF) {
+//             switch (opt) {
+//                     case 'l':
+       ul_log_domain_arg2levels("forb_proto_inet=6");
+//                             break;
+//                     case 'h':
+//                     /\*default:*\/
+//                             usage();
+//                             exit(opt == 'h' ? 0 : 1);
+//             }
+//     }
+
+       ret = WVFRSH(frsh_init());
+       if (ret) exit(1);
+
+       /* Negotiate N contracts */
+       for (i=0; i<N; i++) {
+               ret = WVFRSH(frsh_contract_init(&contract[i]));
+               if (ret) exit(1);
+
+               ret = WVFRSH(frsh_contract_set_resource_and_label(
+                       &contract[i],
+                       DUMMY_RESOURCE_TYPE, DUMMY_RESOURCE_ID,
+                       NULL));
+               if (ret) exit(1);
+
+               budget = fosa_msec_to_rel_time(b[i]);
+               period = fosa_msec_to_rel_time(100);
+               deadline = fosa_msec_to_rel_time(50);
+               ret = WVFRSH(frsh_contract_set_basic_params(&contract[i],
+                                                           &budget,
+                                                           &period,
+                                                           FRSH_WT_BOUNDED,
+                                                           FRSH_CT_REGULAR));
+               if (ret) exit(1);
+               
+               ret = WVFRSH(frsh_contract_set_timing_reqs(&contract[i],
+                                                          false, &deadline));
+               if (ret) exit(1);
+               
+               ret = WVFRSH(frsh_contract_negotiate(&contract[i], &vres[i]));
+               if (ret) exit(1);
+       }
+}
+
+WVTEST_MAIN("renegotiation")
+{
+       for (i=0; i<2 /*N*/; i++) {
+               // FIXME: There is a bug on the test - the 3rd renegotiation fails
+               budget = fosa_msec_to_rel_time(2*b[i]);
+               period = fosa_msec_to_rel_time(110);
+               ret = WVFRSH(frsh_contract_set_basic_params(&contract[i],
+                                                           &budget,
+                                                           &period,
+                                                           FRSH_WT_BOUNDED,
+                                                           FRSH_CT_REGULAR));
+               if (ret) exit(1);
+
+               ret = WVFRSH(frsh_contract_renegotiate_sync(&contract[i], vres[i]));
+               if (ret) exit(1);
+       }
+}
+
+WVTEST_MAIN("cancelation")
+{
+       /* Cancel N contracts */
+       for (i=0; i<N; i++) {
+               ret = WVFRSH(frsh_contract_cancel(vres[i]));
+               if (ret) exit(1);
+       }
+
+       frsh_destroy();
+}
diff --git a/frsh_api/tests/negotiation.sh b/frsh_api/tests/negotiation.sh
new file mode 100755 (executable)
index 0000000..f92a309
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+. $(dirname $0)/wvtest.sh
+
+WVSTART Setup
+WVPASS fcb -dfcb.pid
+WVPASS frm_dummy -dfrm.pid
+WVPASS negotiation.wv
+WVSTART Kill
+WVPASS kill `cat fcb.pid`
+WVPASS rm fcb.pid
+WVPASS kill `cat frm.pid`
+WVPASS rm frm.pid
+
diff --git a/frsh_api/tests/wvtest.sh b/frsh_api/tests/wvtest.sh
new file mode 120000 (symlink)
index 0000000..1982069
--- /dev/null
@@ -0,0 +1 @@
+../../../wvtest.sh
\ No newline at end of file