From 12890ffda147402e4c74b03fec0e39258e0707d5 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" <ldv@altlinux.org> Date: Wed, 27 Apr 2016 00:08:06 +0000 Subject: [PATCH] tests: extend test coverage of umovestr short read condition * tests/umovestr3.c: New file. * tests/umovestr3.test: New test. * tests/.gitignore: Add umovestr3. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add umovestr3.test. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/umovestr3.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ tests/umovestr3.test | 6 ++++++ 4 files changed, 57 insertions(+) create mode 100644 tests/umovestr3.c create mode 100755 tests/umovestr3.test diff --git a/tests/.gitignore b/tests/.gitignore index 8a1e65a3..2d9c4ab8 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -230,6 +230,7 @@ umount umount2 umovestr umovestr2 +umovestr3 uname unix-pair-send-recv unlink diff --git a/tests/Makefile.am b/tests/Makefile.am index 8542aa0a..af667ee9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -282,6 +282,7 @@ check_PROGRAMS = \ umount2 \ umovestr \ umovestr2 \ + umovestr3 \ uname \ unix-pair-send-recv \ unlink \ @@ -543,6 +544,7 @@ DECODER_TESTS = \ umount2.test \ umovestr.test \ umovestr2.test \ + umovestr3.test \ uname.test \ unlink.test \ unlinkat.test \ diff --git a/tests/umovestr3.c b/tests/umovestr3.c new file mode 100644 index 00000000..b4daae06 --- /dev/null +++ b/tests/umovestr3.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "tests.h" +#include <stdio.h> +#include <unistd.h> + +int +main(void) +{ + const unsigned int size = 8; + const char *const p = tail_alloc(size); + const char *const efault = p + size; + (void) tail_alloc(1); + + int rc = chdir(p); + printf("chdir(%p) = %d %s (%m)\n", p, rc, errno2name()); + + rc = chdir(efault); + printf("chdir(%p) = %d %s (%m)\n", efault, rc, errno2name()); + + puts("+++ exited with 0 +++"); + return 0; +} diff --git a/tests/umovestr3.test b/tests/umovestr3.test new file mode 100755 index 00000000..d5be2832 --- /dev/null +++ b/tests/umovestr3.test @@ -0,0 +1,6 @@ +#!/bin/sh + +# yet another umovestr short read test + +. "${srcdir=.}/init.sh" +run_strace_match_diff -a14 -e trace=chdir -- 2.40.0