From: Jonathan Dieter Date: Mon, 8 Oct 2018 15:22:11 +0000 (+0100) Subject: Convert shacheck to c to aid in finding memory leaks (bash is horribly X-Git-Tag: archive/raspbian/1.1.9+ds1-1+rpi1~1^2~87 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0b8e2157a27243645bdb8cbfdcce4a9d879e83d3;p=zchunk.git Convert shacheck to c to aid in finding memory leaks (bash is horribly leaky) Signed-off-by: Jonathan Dieter --- diff --git a/test/meson.build b/test/meson.build index f7a468f..714ae3d 100644 --- a/test/meson.build +++ b/test/meson.build @@ -3,7 +3,7 @@ subdir('lib') incdir = include_directories(['lib', '../src/lib', '../include']) empty = executable('empty', ['empty.c'] + util_sources, include_directories: incdir, dependencies: [zstd_dep, openssl_dep]) optflag = executable('optflag', ['optflag.c'] + util_sources, include_directories: incdir, dependencies: [zstd_dep, openssl_dep]) -shacheck = find_program('shacheck.sh') +shacheck = executable('shacheck', ['shacheck.c'] + util_sources, include_directories: incdir, dependencies: [zstd_dep, openssl_dep]) file_path = join_paths(meson.source_root(), 'test/files') test( diff --git a/test/shacheck.c b/test/shacheck.c new file mode 100644 index 0000000..b65bb28 --- /dev/null +++ b/test/shacheck.c @@ -0,0 +1,103 @@ +/* + * Copyright 2018 Jonathan Dieter + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "zck_private.h" +#include "util.h" + +int main (int argc, char *argv[]) { + if(argc < 4) { + printf("Usage: %s [args]\n", + argv[0]); + exit(1); + } + + char *cmd = argv[1]; + char *outf = argv[2]; + char *echecksum = argv[3]; + + char **args = calloc(argc-2, sizeof(void*)); + + args[0] = argv[1]; + for(int i=1; i