[CRIU] [PATCH]v2 zdtm: test semi-closed unix stream connection for data loss
Andrew Vagin
avagin at parallels.com
Mon Aug 26 17:07:27 EDT 2013
On Mon, Aug 26, 2013 at 09:27:27PM +0400, Ruslan Kuprieiev wrote:
> Hi!
>
> Added test for data loss in semi-closed stream unix connection.
Why do you decide to add a new test? In a previous attempt you tryed to
expand the socket02 test and I think it was the right way.
You replaced one check on another and I suggested to add one more check
and do nothing with the previous one.
> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
>
> diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
> index f76e61b..68c147e 100644
> --- a/test/zdtm/live/static/Makefile
> +++ b/test/zdtm/live/static/Makefile
> @@ -48,6 +48,7 @@ TST_NOFILE = \
> pstree \
> sockets01 \
> sockets02 \
> + sockets03 \
> sockets_spair \
> socket_queues \
> socket_queues02 \
> diff --git a/test/zdtm/live/static/sockets03.c b/test/zdtm/live/static/sockets03.c
> new file mode 100644
> index 0000000..82d67db
> --- /dev/null
> +++ b/test/zdtm/live/static/sockets03.c
> @@ -0,0 +1,52 @@
> +#define _GNU_SOURCE
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <ctype.h>
> +#include <errno.h>
> +#include <unistd.h>
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <sys/wait.h>
> +#include <sys/un.h>
> +#include <sys/stat.h>
> +#include <limits.h>
> +#include <fcntl.h>
> +#include <time.h>
> +
> +#include "zdtmtst.h"
> +
> +const char *test_doc = "Test semi-closed unix stream connection "
> + "for data loss\n";
> +const char *test_author = "Ruslan Kuprieiev <kupruser at gmail.com>\n";
> +
> +int main(int argc, char *argv[])
> +{
> + int ssk_pair[2], ret;
> + char wdata, rdata;
> +
> + srandom(time(NULL));
> + wdata = (char)random();
> +
> + test_init(argc, argv);
> +
> + if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
> + fail("socketpair\n");
> + exit(1);
> + }
> +
> + write(ssk_pair[1], &wdata, sizeof(wdata));
> + close(ssk_pair[1]);
> +
> + test_daemon();
> + test_waitsig();
> +
> + ret = read(ssk_pair[0], &rdata, sizeof(rdata));
> + if (rdata != wdata || ret != sizeof(rdata)) {
> + fail("Data loss (write %d/read %d)", wdata, rdata);
> + return 0;
> + }
> +
> + pass();
> + return 0;
> +}
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list