compel/test: fix "infect" test compilation errors

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Mike Rapoport 2017-08-24 14:57:41 +03:00 committed by Andrei Vagin
parent 82cb4b4bd4
commit dc4d61f84f
3 changed files with 18 additions and 6 deletions

View file

@ -1,6 +1,7 @@
#include <errno.h>
#include <compel/plugins/std.h>
#include <infect-rpc.h>
/*
* Stubs for std compel plugin.

View file

@ -87,7 +87,9 @@ static inline int chk(int fd, int val)
{
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);
return v == val;
}
@ -118,8 +120,12 @@ int main(int argc, char **argv)
/*
* Tell the little guy some numbers
*/
i = 1; write(p_in[1], &i, sizeof(i));
i = 42; write(p_in[1], &i, sizeof(i));
i = 1;
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");
pass = chk(p_out[0], 1);
@ -138,8 +144,12 @@ int main(int argc, char **argv)
/*
* Tell the victim some more stuff to check it's alive
*/
i = 1234; write(p_in[1], &i, sizeof(i));
i = 4096; write(p_in[1], &i, sizeof(i));
i = 1234;
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

View file

@ -8,7 +8,8 @@ int main(int argc, char **argv)
if (read(0, &i, sizeof(i)) != sizeof(i))
break;
write(1, &i, sizeof(i));
if (write(1, &i, sizeof(i)) != sizeof(i))
break;
}
return 0;