From: Philipp Gesang Date: Tue, 2 Jan 2018 15:13:30 +0000 (+0100) Subject: add unit test series for pipestream X-Git-Tag: v2.10~1^2~16 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=3ed2cc9bcc064e94376294526d785af7158e5be3;p=libi2ncommon add unit test series for pipestream Setup skeleton unit test file with some simple functionality tests and include it in a normal run. There haven't been any pipestream tests so far. --- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2928716..ecd259b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,6 +17,7 @@ SET(cpp_sources test_logging.cpp test_pidfile.cpp test_restricted_html.cpp + test_pipestream.cpp test_timefunc.cpp test_tmpfstream.cpp test_tribool.cpp diff --git a/test/test_pipestream.cpp b/test/test_pipestream.cpp new file mode 100644 index 0000000..a58c89a --- /dev/null +++ b/test/test_pipestream.cpp @@ -0,0 +1,64 @@ +/* + * The software in this package is distributed under the GNU General + * Public License version 2 (with a special exception described below). + * + * A copy of GNU General Public License (GPL) is included in this distribution, + * in the file COPYING.GPL. + * + * As a special exception, if other files instantiate templates or use macros + * or inline functions from this file, or you compile this file and link it + * with other works to produce a work based on this file, this file + * does not by itself cause the resulting work to be covered + * by the GNU General Public License. + * + * However the source code for this file must still be made available + * in accordance with section (3) of the GNU General Public License. + * + * This exception does not invalidate any other reasons why a work based + * on this file might be covered by the GNU General Public License. + * + * @file + * + * unit tests for the module "pipestream" + * + * Copyright 2018 by Intra2net AG + */ + + +#define BOOST_TEST_DYN_LINK +#include +#include + +#include "stringfunc.hxx" +#include "pipestream.hxx" + +#define TO_CHARP_TOK(x) #x +#define TO_CHARP(x) TO_CHARP_TOK(x) + +BOOST_AUTO_TEST_SUITE(pipestream) + + BOOST_AUTO_TEST_SUITE(read) + + # define ENOUGH_ZEROS 42 + const char *const zero_bytes_argv [] = + { "/usr/bin/head", "-c", TO_CHARP(ENOUGH_ZEROS), "/dev/zero", NULL }; + + BOOST_AUTO_TEST_CASE(abspath_zeros_shell_ok) + { + const std::string result = + capture_exec (I2n::join_string (zero_bytes_argv, " ")); + + BOOST_CHECK_EQUAL(result.size (), ENOUGH_ZEROS); + } + + BOOST_AUTO_TEST_CASE(abspath_zeros_noshell_ok) + { + const std::string result = capture_exec (zero_bytes_argv); + + BOOST_CHECK_EQUAL(result.size (), ENOUGH_ZEROS); + } + + BOOST_AUTO_TEST_SUITE_END() /* [pipestream->read] */ + +BOOST_AUTO_TEST_SUITE_END() /* [pipestream] */ +