[CRIU] [PATCH]v2 zdtm: test semi-closed unix stream connection for data loss
Andrew Vagin
avagin at parallels.com
Tue Aug 27 00:28:04 EDT 2013
On Tue, Aug 27, 2013 at 01:38:42AM +0400, Ruslan Kuprieiev wrote:
> On 08/27/2013 01:07 AM, Andrew Vagin wrote:
> >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.
> >
> It was impulsive decision=).
> Here is one more try.
> If this patch is ok, please, tell me if i should send it again with
> [PATCH]v3 tag.
> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
>
> diff --git a/test/zdtm/live/static/sockets02.c b/test/zdtm/live/static/sockets02.c
> index 8ff38f8..3e6829d 100644
> --- a/test/zdtm/live/static/sockets02.c
> +++ b/test/zdtm/live/static/sockets02.c
> @@ -12,6 +12,7 @@
> #include <sys/stat.h>
> #include <limits.h>
> #include <fcntl.h>
> +#include <time.h>
>
> #include "zdtmtst.h"
>
> @@ -21,7 +22,10 @@ const char *test_author = "Pavel Emelyanov <xemul at parallels.com>\n";
> int main(int argc, char *argv[])
> {
> int ssk_pair[2], ret;
> - char aux;
> + char aux, data;
> +
> + srandom(time(NULL));
> + data = (char)random();
>
> test_init(argc, argv);
>
> @@ -30,6 +34,12 @@ int main(int argc, char *argv[])
> exit(1);
> }
>
> + ret = write(ssk_pair[1], &data, sizeof(data));
> + if (ret != sizeof(data)) {
> + fail("write\n");
> + exit(1);
> + }
> +
> close(ssk_pair[1]);
>
> test_daemon();
> @@ -37,9 +47,12 @@ int main(int argc, char *argv[])
>
We need to check data and the state of socket. I think we can add a
separate check for data.
+
+ ret = read(ssk_pair[0], &aux, sizeof(aux));
+ if (ret != sizeof(data) && aux != data) {
+ fail("Data loss (write %d/read %d)", data, aux);
+ return 1;
+ }
+
errno = 0;
ret = read(ssk_pair[0], &aux, sizeof(aux));
if (ret != 0 || errno != 0) {
fail("Opened end in wrong state (%d/%d)", ret, errno);
return 0;
}
errno = 0;
More information about the CRIU
mailing list