//! //! Main entry point of the application //! //! @param[in] argc the number of parameter passed on the command line //! @param[in] argv the list of arguments //! //! @return Always return 0 //! int main(int argc, char **argv) { printf("=====> testing misc.c\n"); test_command("date"); test_command("ls / -l | sort"); test_command("/foo"); { char c = 0; long l = 0; int i = 0; long long ll = 0; euca_lscanf("a1\na\na2\n", "a%d", &i); assert(i == 1); euca_lscanf("a\nab3\na 4\na5", "a %d", &i); assert(i == 4); euca_lscanf("", "%d", &i); euca_lscanf("\n\n\n", "%d", &i); euca_lscanf("abcdefg6", "g%d", &i); assert(i != 6); euca_lscanf("abcdefg", "ab%cdefg", &c); assert(c == 'c'); euca_lscanf("a\na 7\na\n", "a %ld", &l); assert(l == 7L); euca_lscanf("a\n8a\na9\n", "a %lld", &ll); assert(ll == 9L); } printf("=====> testing auth.c\n"); { //int decrypt_string_with_node_and_symmetric_key(char *in_buffer, char *key_buffer, char**out_buffer) euca_init_cert(); char *encrypted_symm_key = "YCvEugV7FynwQnyDbNX8hVFstseIpzhBCi6nxWZOUhVbivEf9Frkk7evxvQeSn9GUIvyNSE15Stts/CQmIGNsAKpAmjUoDzkkB/8EUCO9bgVi6IQl6SOzZCqX1hGCMZT1Ir32HXcwZcEbtDl0WpfLahjT9pZQAtDnnRT7H8+qysxUbEoL9Z2Yw5GneF5hRDWcA9Kce617oNbPFiZjLnnQr2iNsxyWb8LVj7KnBweJ8UJumgcWp26VsWoBUUCK/3adPAvOk/kalgrXZAk6fo/TqGUqdokjj1tz3rG7dcvTRuB0qwY1P8KfgRg3HABQcHjriKNvBYTVDhhEFDP2v0fiA=="; char *encrypted_string = "yuDM7HLybe+7DdkYFt+7zXYCeB/WHIdXSw7eF14L8YONEWmZdTEJwgXcGYdRpfDlY821xYi3asgURP6k9gFtPxjDHv/VcEKENJk9i/RbiAp0rEZ+gmkN3HQE9PjfNmS83AS1OyUnDiK2VcFRID7QKHcMdGrL6EXg/0QT1cDuwF0VbL71tdSddpFUHanaHQy2PzqKVPjfAqKWDBanMZWXck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9ccKsAWa1zvvfCzGgqONoJ499rGFsY6H81jXR4h8K2o9n/Xs/8Sp8I8IqWfmS/JKH21JquJi4gLpmmZ38Kv6V4R7j5YcB9YwnIfav/uAJTN9VD9NKOyFwfhDA2YT4ErzMk5UL3sfQIX6UCzaKCiOeH3nKHzM7X4aHSqtSbvVNVxQ0tMYvm2oVEojmaXWGHmWyoylXJ1v0eaK38SDzwdpef6UKXESPEMpnR0krqH8bC7lZyMx2OyKpse9hJbjhzOvgv91lkUG3kidPxKraTUwXUmxVlUgxfcCgknO93U+kopjiffJDe/xILawvpEq0KWBFfbFN679znyz+8AEud2WSYdz7KnYuoX3RmViid/Oj0w=="; char *decrypted = NULL; int out_len = -1; if (decrypt_string_with_node_and_symmetric_key(encrypted_string, encrypted_symm_key, &decrypted, &out_len) != EUCA_OK) { printf("failed to decrypt using symmetric key\n"); } else { printf("decrypted length: %d\n", out_len); } } printf("=====> testing data.c\n"); { #define INSTS 50 bunchOfInstances *bag = NULL; ncInstance *inst = NULL; ncInstance *Insts[INSTS]; int i, n; printf("========> testing instance struct management\n"); free_instance(NULL); free_instance(&inst); inst = allocate_instance("the-uuid", "i1", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0); assert(inst != NULL); free_instance(&inst); assert(inst == NULL); n = total_instances(&bag); assert(n == 0); bag = NULL; inst = find_instance(&bag, "foo"); assert(inst == NULL); bag = NULL; n = remove_instance(&bag, NULL); assert(n != EUCA_OK); bag = NULL; for (i = 0; i < INSTS; i++) { char id[10]; sprintf(id, "i-%d", i); inst = Insts[i] = allocate_instance("the-uuid", id, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0); assert(inst != NULL); n = add_instance(&bag, inst); assert(n == EUCA_OK); } n = total_instances(&bag); assert(n == INSTS); n = remove_instance(&bag, Insts[0]); assert(n == EUCA_OK); n = remove_instance(&bag, Insts[INSTS - 1]); assert(n == EUCA_OK); n = total_instances(&bag); assert(n == INSTS - 2); printf("========> testing volume struct management\n"); ncVolume *v; inst = allocate_instance("the-uuid", "i2", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0); assert(inst != NULL); for (i = 0; i < EUCA_MAX_VOLUMES; i++) { char id[10]; sprintf(id, "v-%d", i); v = save_volume(inst, id, "tok", "rd", "ld", "ldr", VOL_STATE_ATTACHED); assert(v != NULL); } assert(is_volume_used(v)); assert(save_volume(inst, "too-much", "tok", "rd", "ld", "ldr", VOL_STATE_ATTACHED) == NULL); assert(save_volume(inst, v->volumeId, NULL, NULL, NULL, NULL, NULL) != NULL); assert(save_volume(inst, v->volumeId, NULL, "RD", NULL, NULL, NULL) != NULL); assert(save_volume(inst, v->volumeId, NULL, NULL, "LD", NULL, NULL) != NULL); assert(save_volume(inst, v->volumeId, NULL, NULL, NULL, "LDR", NULL) != NULL); assert(save_volume(inst, v->volumeId, NULL, NULL, NULL, NULL, VOL_STATE_DETACHED) != NULL); assert(strcmp(v->attachmentToken, "RD") == 0); assert(save_volume(inst, "v-x1", NULL, NULL, NULL, NULL, VOL_STATE_ATTACHING) != NULL); assert(save_volume(inst, "v-x2", NULL, NULL, NULL, NULL, VOL_STATE_ATTACHING) == NULL); assert(save_volume(inst, "v-x1", NULL, NULL, NULL, NULL, VOL_STATE_DETACHING) != NULL); assert(save_volume(inst, "v-x2", NULL, NULL, NULL, NULL, VOL_STATE_ATTACHING) == NULL); assert(save_volume(inst, "v-x1", NULL, NULL, NULL, NULL, VOL_STATE_DETACHING_FAILED) != NULL); assert(save_volume(inst, "v-x2", NULL, NULL, NULL, NULL, VOL_STATE_ATTACHING) == NULL); assert(free_volume(inst, "v-x1") != NULL); for (i = 0; i < EUCA_MAX_VOLUMES - 1; i++) { char id[10]; sprintf(id, "v-%d", i); v = free_volume(inst, id); assert(v != NULL); } free_instance(&inst); assert(inst == NULL); } printf("OK\n"); return 0; }
//! //! Main entry point of the application //! //! @param[in] argc the number of parameter passed on the command line //! @param[in] argv the list of arguments //! //! @return Always return 0 //! int main(int argc, char **argv) { printf("=====> testing misc.c\n"); test_command("date"); test_command("ls / -l | sort"); test_command("/foo"); { char c = 0; long l = 0; int i = 0; long long ll = 0; euca_lscanf("a1\na\na2\n", "a%d", &i); assert(i == 1); euca_lscanf("a\nab3\na 4\na5", "a %d", &i); assert(i == 4); euca_lscanf("", "%d", &i); euca_lscanf("\n\n\n", "%d", &i); euca_lscanf("abcdefg6", "g%d", &i); assert(i != 6); euca_lscanf("abcdefg", "ab%cdefg", &c); assert(c == 'c'); euca_lscanf("a\na 7\na\n", "a %ld", &l); assert(l == 7L); euca_lscanf("a\n8a\na9\n", "a %lld", &ll); assert(ll == 9L); } printf("=====> testing data.c\n"); { #define INSTS 50 bunchOfInstances *bag = NULL; ncInstance *inst = NULL; ncInstance *Insts[INSTS]; int i, n; printf("========> testing instance struct management\n"); free_instance(NULL); free_instance(&inst); inst = allocate_instance("the-uuid", "i1", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0); assert(inst != NULL); free_instance(&inst); assert(inst == NULL); n = total_instances(&bag); assert(n == 0); bag = NULL; inst = find_instance(&bag, "foo"); assert(inst == NULL); bag = NULL; n = remove_instance(&bag, NULL); assert(n != EUCA_OK); bag = NULL; for (i = 0; i < INSTS; i++) { char id[10]; sprintf(id, "i-%d", i); inst = Insts[i] = allocate_instance("the-uuid", id, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0); assert(inst != NULL); n = add_instance(&bag, inst); assert(n == EUCA_OK); } n = total_instances(&bag); assert(n == INSTS); n = remove_instance(&bag, Insts[0]); assert(n == EUCA_OK); n = remove_instance(&bag, Insts[INSTS - 1]); assert(n == EUCA_OK); n = total_instances(&bag); assert(n == INSTS - 2); printf("========> testing volume struct management\n"); ncVolume *v; inst = allocate_instance("the-uuid", "i2", NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0); assert(inst != NULL); for (i = 0; i < EUCA_MAX_VOLUMES; i++) { char id[10]; sprintf(id, "v-%d", i); v = save_volume(inst, id, "rd", "ld", "ldr", VOL_STATE_ATTACHED); assert(v != NULL); } assert(is_volume_used(v)); assert(save_volume(inst, "too-much", "rd", "ld", "ldr", VOL_STATE_ATTACHED) == NULL); assert(save_volume(inst, v->volumeId, NULL, NULL, NULL, NULL) != NULL); assert(save_volume(inst, v->volumeId, "RD", NULL, NULL, NULL) != NULL); assert(save_volume(inst, v->volumeId, NULL, "LD", NULL, NULL) != NULL); assert(save_volume(inst, v->volumeId, NULL, NULL, "LDR", NULL) != NULL); assert(save_volume(inst, v->volumeId, NULL, NULL, NULL, VOL_STATE_DETACHED) != NULL); assert(strcmp(v->remoteDev, "RD") == 0); assert(save_volume(inst, "v-x1", NULL, NULL, NULL, VOL_STATE_ATTACHING) != NULL); assert(save_volume(inst, "v-x2", NULL, NULL, NULL, VOL_STATE_ATTACHING) == NULL); assert(save_volume(inst, "v-x1", NULL, NULL, NULL, VOL_STATE_DETACHING) != NULL); assert(save_volume(inst, "v-x2", NULL, NULL, NULL, VOL_STATE_ATTACHING) == NULL); assert(save_volume(inst, "v-x1", NULL, NULL, NULL, VOL_STATE_DETACHING_FAILED) != NULL); assert(save_volume(inst, "v-x2", NULL, NULL, NULL, VOL_STATE_ATTACHING) == NULL); assert(free_volume(inst, "v-x1") != NULL); for (i = 0; i < EUCA_MAX_VOLUMES - 1; i++) { char id[10]; sprintf(id, "v-%d", i); v = free_volume(inst, id); assert(v != NULL); } free_instance(&inst); assert(inst == NULL); } printf("OK\n"); return 0; }