Commit dc4d61f8 authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

compel/test: fix "infect" test compilation errors

Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 82cb4b4b
#include <errno.h> #include <errno.h>
#include <compel/plugins/std.h> #include <compel/plugins/std.h>
#include <infect-rpc.h>
/* /*
* Stubs for std compel plugin. * Stubs for std compel plugin.
......
...@@ -87,7 +87,9 @@ static inline int chk(int fd, int val) ...@@ -87,7 +87,9 @@ static inline int chk(int fd, int val)
{ {
int v = 0; int v = 0;
read(fd, &v, sizeof(v)); if (read(fd, &v, sizeof(v)) != sizeof(v))
return 0;
printf("%d, want %d\n", v, val); printf("%d, want %d\n", v, val);
return v == val; return v == val;
} }
...@@ -118,8 +120,12 @@ int main(int argc, char **argv) ...@@ -118,8 +120,12 @@ int main(int argc, char **argv)
/* /*
* Tell the little guy some numbers * Tell the little guy some numbers
*/ */
i = 1; write(p_in[1], &i, sizeof(i)); i = 1;
i = 42; write(p_in[1], &i, sizeof(i)); if (write(p_in[1], &i, sizeof(i)) != sizeof(i))
return 1;
i = 42;
if (write(p_in[1], &i, sizeof(i)) != sizeof(i))
return 1;
printf("Checking the victim alive\n"); printf("Checking the victim alive\n");
pass = chk(p_out[0], 1); pass = chk(p_out[0], 1);
...@@ -138,8 +144,12 @@ int main(int argc, char **argv) ...@@ -138,8 +144,12 @@ int main(int argc, char **argv)
/* /*
* Tell the victim some more stuff to check it's alive * Tell the victim some more stuff to check it's alive
*/ */
i = 1234; write(p_in[1], &i, sizeof(i)); i = 1234;
i = 4096; write(p_in[1], &i, sizeof(i)); if (write(p_in[1], &i, sizeof(i)) != sizeof(i))
return 1;
i = 4096;
if (write(p_in[1], &i, sizeof(i)) != sizeof(i))
return 1;
/* /*
* Stop the victim and check the infection went well * Stop the victim and check the infection went well
......
...@@ -8,7 +8,8 @@ int main(int argc, char **argv) ...@@ -8,7 +8,8 @@ int main(int argc, char **argv)
if (read(0, &i, sizeof(i)) != sizeof(i)) if (read(0, &i, sizeof(i)) != sizeof(i))
break; break;
write(1, &i, sizeof(i)); if (write(1, &i, sizeof(i)) != sizeof(i))
break;
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment