direct-io.hg
changeset 6046:61af128313c8
Remove dead file.
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Mon Aug 08 11:10:54 2005 +0000 (2005-08-08) |
parents | 704e6cc4a684 |
children | 7d84bc707736 |
files |
line diff
1.1 --- a/tools/xenstore/xs_watch_stress.c Mon Aug 08 11:06:45 2005 +0000 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,120 +0,0 @@ 1.4 -/* Stress test for watch code: two processes communicating by watches */ 1.5 -#include "xs.h" 1.6 -#include "utils.h" 1.7 -#include <stdlib.h> 1.8 -#include <stdio.h> 1.9 -#include <sys/types.h> 1.10 -#include <sys/wait.h> 1.11 -#include <sys/stat.h> 1.12 -#include <fcntl.h> 1.13 -#include <unistd.h> 1.14 - 1.15 -int main(int argc __attribute__((unused)), char *argv[]) 1.16 -{ 1.17 - int childpid, status, fds[2]; 1.18 - bool parent; 1.19 - unsigned int i, acks = 0; 1.20 - struct xs_handle *h; 1.21 - char *data; 1.22 - unsigned int len; 1.23 - const char *path, *otherpath; 1.24 - 1.25 - pipe(fds); 1.26 - childpid = fork(); 1.27 - if (childpid == -1) 1.28 - barf_perror("Failed fork"); 1.29 - parent = (childpid != 0); 1.30 - 1.31 - h = xs_daemon_open(); 1.32 - if (!h) 1.33 - barf_perror("Could not connect to daemon"); 1.34 - 1.35 - if (!xs_watch(h, "/", "token", 0)) 1.36 - barf_perror("Could not set watch"); 1.37 - 1.38 - if (parent) { 1.39 - char c; 1.40 - 1.41 - if (read(fds[0], &c, 1) != 1) 1.42 - barf("Child exited"); 1.43 - 1.44 - path = "/parent"; 1.45 - otherpath = "/child"; 1.46 - /* Create initial node. */ 1.47 - if (!xs_write(h, path, "0", 2, O_CREAT)) 1.48 - barf_perror("Write to %s failed", path); 1.49 - } else { 1.50 - path = "/child"; 1.51 - otherpath = "/parent"; 1.52 - 1.53 - if (write(fds[1], "", 1) != 1) 1.54 - barf_perror("Write to parent failed"); 1.55 - } 1.56 - 1.57 - for (i = 0; i < (argv[1] ? (unsigned)atoi(argv[1]) : 100);) { 1.58 - char **vec; 1.59 - 1.60 - vec = xs_read_watch(h); 1.61 - if (!vec) 1.62 - barf_perror("Read watch failed"); 1.63 - 1.64 - if (!streq(vec[1], "token")) 1.65 - barf("Watch token %s bad", vec[1]); 1.66 - if (streq(vec[0], otherpath)) { 1.67 - char number[32]; 1.68 - 1.69 - data = xs_read(h, otherpath, &len); 1.70 - if (!data) 1.71 - barf_perror("reading %s", otherpath); 1.72 - sprintf(number, "%i", atoi(data) + 1); 1.73 - free(data); 1.74 - if (!xs_write(h, path, number, strlen(number) + 1, 1.75 - O_CREAT)) 1.76 - barf_perror("writing %s", path); 1.77 - i++; 1.78 - } else if (!streq(vec[0], path)) 1.79 - barf_perror("Watch fired on unknown path %s", vec[0]); 1.80 - xs_acknowledge_watch(h, vec[1]); 1.81 - acks++; 1.82 - free(vec); 1.83 - } 1.84 - 1.85 - if (!parent) { 1.86 - while (acks != 2 * i - 1) { 1.87 - char **vec; 1.88 - vec = xs_read_watch(h); 1.89 - if (!vec) 1.90 - barf_perror("Watch failed"); 1.91 - if (!streq(vec[0], path)) 1.92 - barf_perror("Watch fired path %s", vec[0]); 1.93 - if (!streq(vec[1], "token")) 1.94 - barf("Watch token %s bad", vec[1]); 1.95 - free(vec); 1.96 - 1.97 - printf("Expect %i events, only got %i\n", 1.98 - 2 * i - 1, acks); 1.99 - acks++; 1.100 - } 1.101 - exit(0); 1.102 - } 1.103 - 1.104 - if (acks != 2 * i) 1.105 - barf("Parent got %i watch events\n", acks); 1.106 - 1.107 - printf("Waiting for %i\n", childpid); 1.108 - if (waitpid(childpid, &status, 0) != childpid) 1.109 - barf_perror("Child wait failed"); 1.110 - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) 1.111 - barf_perror("Child status %i", status); 1.112 - 1.113 - data = xs_read(h, path, &len); 1.114 - if (atoi(data) != 2 * (int)i) 1.115 - barf("%s count is %s\n", path, data); 1.116 - free(data); 1.117 - data = xs_read(h, otherpath, &len); 1.118 - if (atoi(data) != 2 * (int)i - 1) 1.119 - barf("%s count is %s\n", otherpath, data); 1.120 - free(data); 1.121 - printf("Success!\n"); 1.122 - exit(0); 1.123 -}