[CRIU] [PATCH] compel/test: fix "infect" test compilation errors
Mike Rapoport
rppt at linux.vnet.ibm.com
Thu Aug 24 14:57:41 MSK 2017
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
compel/test/infect/parasite.c | 1 +
compel/test/infect/spy.c | 20 +++++++++++++++-----
compel/test/infect/victim.c | 3 ++-
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/compel/test/infect/parasite.c b/compel/test/infect/parasite.c
index bdbe722..f185809 100644
--- a/compel/test/infect/parasite.c
+++ b/compel/test/infect/parasite.c
@@ -1,6 +1,7 @@
#include <errno.h>
#include <compel/plugins/std.h>
+#include <infect-rpc.h>
/*
* Stubs for std compel plugin.
diff --git a/compel/test/infect/spy.c b/compel/test/infect/spy.c
index b8a65c3..a5aba73 100644
--- a/compel/test/infect/spy.c
+++ b/compel/test/infect/spy.c
@@ -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
diff --git a/compel/test/infect/victim.c b/compel/test/infect/victim.c
index b37688b..f94613f 100644
--- a/compel/test/infect/victim.c
+++ b/compel/test/infect/victim.c
@@ -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;
--
2.7.4
More information about the CRIU
mailing list