Revision 0e9bde83 src/Tests/cloud_test.c

View differences:

src/Tests/cloud_test.c
5 5
 *
6 6
 *  This is a small test program for the cloud interface
7 7
 *  To try the simple test: run it with
8
 *    ./cloud_test -c "provider=<cloud_provider>,<provider_opts>" [-g key | -p key=value | -n | -e ip:port]
8
 *    ./cloud_test -c "provider=<cloud_provider>,<provider_opts>" [-g key | -p key=value | -n variant | -e ip:port]
9 9
 *
10 10
 *    -g  GET key from cloud
11 11
 *    -p  PUT key=value on cloud
12
 *    -n  print the cloud node
12
 *    -n  print the cloud node for the specified variant
13 13
 *    -e  check if ip:port references the cloud
14 14
 *    -c  set the configuration of the cloud provider
15 15
 *
......
35 35

  
36 36
static const char *config;
37 37
static int operation;
38
static int variant;
38 39
static char *key;
39 40
static char *value;
40 41

  
......
46 47
  int o;
47 48
  char *temp;
48 49
      
49
  while ((o = getopt(argc, argv, "c:g:p:ne:")) != -1) {
50
  while ((o = getopt(argc, argv, "c:g:p:n:e:")) != -1) {
50 51
    switch(o) {
51 52
    case 'c':
52 53
      config = strdup(optarg);
......
69 70
        break;
70 71
    case 'n':
71 72
      operation = GET_CLOUD_NODE;
73
      variant = atoi(optarg);
72 74
      break;
73 75
    case 'e':
74 76
      operation = EQ_CLOUD_NODE;
......
154 156
      } else if (err == 0) {
155 157
	printf("Key not present on the cloud\n");
156 158
      } else {
159
        time_t timestamp;
157 160
	buffer[sizeof(buffer) - 1] = '\0';
158 161
	printf("%s\n", buffer);
162
        timestamp = timestamp_cloud(cloud);
163
        printf("Timestamp: %s\n", ctime(&timestamp));
159 164
      }
160 165
    } else if (err == 0){
161 166
      printf("No response from cloud\n");
......
168 173
    }
169 174
    break;
170 175
  case GET_CLOUD_NODE:
171
    printf("Cloud node: %s\n", node_addr(get_cloud_node(cloud)));
176
    printf("Cloud node: %s\n", node_addr(get_cloud_node(cloud, variant)));
172 177
    break;
173 178
  case EQ_CLOUD_NODE:
174 179
    t = create_node(key, atoi(value));
175
    printf("Node %s references cloud? %d\n", node_addr(get_cloud_node(cloud)),
180
    printf("Node %s references cloud? %d\n", node_addr(get_cloud_node(cloud, variant)),
176 181
	   is_cloud_node(cloud, t));
177 182
    break;
178 183
  }

Also available in: Unified diff