Compare commits

...
18 Commits
Author SHA1 Message Date
Joachim Nilsson ef04307b4a debian: Update symbols file, new APIs introduced in v2.2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:41:44 +01:00
Joachim Nilsson 5d035d955e debian: Add missing libtool to Build-Depends
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:38:25 +01:00
Joachim Nilsson b65175782d Bump ABI version, new APIs added
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 17:38:25 +01:00
Joachim Nilsson c27a8e7ec6 Update changelogs and bump version for v2.2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 16:01:46 +01:00
Joachim Nilsson d231c1e1eb Revert "Travis-CI: Disable clang temporarily for Coverity Scan run"
This reverts commit 2a6adeebcd.
2020-03-16 10:41:27 +01:00
Joachim Nilsson 247fb67274 Add Coverity Scan badge
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:37:21 +01:00
Joachim Nilsson c716cc5835 copyfile(): Check return value of fstat(), prevent faulty futimens()
Found by Coverity Scan

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:50 +01:00
Joachim Nilsson e81ce85867 rsync(): Fix possible memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:50 +01:00
Joachim Nilsson 549f325c21 rsync(): Fix variable shadowing, found by clang-tidy
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-16 10:31:46 +01:00
Joachim Nilsson 2a6adeebcd Travis-CI: Disable clang temporarily for Coverity Scan run
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:56:23 +01:00
Joachim Nilsson cb2beacf2c Travis-CI: Add support for Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:55:27 +01:00
Joachim Nilsson 256b6ba038 Add origin section to README, better place for history or project
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:48:55 +01:00
Joachim Nilsson 61d9b5fac7 Update Changelog for upcoming v2.2.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:43:48 +01:00
Joachim Nilsson 38ad841389 Bump version for v2.2.0 release cycle
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:39:17 +01:00
Joachim Nilsson f1a1a21569 Add support for systemf(), formatted system() replacement
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-14 10:32:52 +01:00
Joachim Nilsson 7f3f4df9e9 Add support for fmkpath(), formatted string mkpath()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-11 20:03:03 +01:00
Joachim Nilsson 02a42a1cad Add support for fopenf(), formatted string fopen()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-10 09:07:56 +01:00
Joachim Nilsson 28c11f010a Check for existence of AM_PROG_AR macro
This patch facilitates building newer versions of libite on systems with
older versions of autoconf and automake.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-02-22 15:47:28 +01:00
20 changed files with 364 additions and 33 deletions

No files matched your search

+19
View File
@@ -10,6 +10,25 @@ compiler:
- gcc
- clang
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "EcWeDUONZnl7IHBWD2rc92LwTWGIlqBZ7wQrLfe3mFXOnB+IZjJIBnDsJDnHDWwA8fGF9NaJbRz4BThroafueUwkDXNyvph1Mdaxm6mdMPyjNJ4H1AFkd9Fz0LYdLNXCPl43tm6s1BR6OWts17lWF6sMnMmIu8gUgXJVg2qsDBl3O9eCoRvQ/h4elLfXZ03fHi4XzzzQvZVyDCg8MCzXIgHJzdkv4llpiCLWQExFbIAVy39euDnx+UuWYB7WDdUbOc7HkkUwf0/vX9PhKVQFKOkXn1ddN0iCsWRH3ti5KXWrBeRO3RPu6Z5YtR8l1WK7iqCYOLuMBW23tXsBQsIW09f1+fFgJ8Ig5hHRRbDinbTUb+mHUJZmNv9ZTc3hPYH4Fyev/ljk42VVDdIBy9AqO42jj8VGmDmiIq47aqNJZUGYZgQlGXGqk9MtavJrqEVcFSgyfEtI+c4n4fzvMRpcEwjnbp482s1xNzHQZ1GQI77Td5UUXXWyNSCoQoE/VpkAesYJAw8KwXOXveDr3Qu0HhuQu1oyLmWHlZHYDu+TInjY81gpGw9Cm7/SdFoA0Ag49PlAXdPRymbP01B50MqrCTxtXEHtdXxhrkDvaoUp7heSuvO0fS+mI5F7eQ4Ji2JdyRSt1KpXVNAyL1FrO/yznM3EwcXPmWmrc+QjFtC9vY4="
before_install:
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
addons:
coverity_scan:
project:
name: "troglobit/libite"
description: "That missing frog DNA you've been looking for"
notification_email: troglobit@gmail.com
build_command_prepend: "./autogen.sh && ./configure --prefix=/tmp --disable-silent-rules"
build_command: "make clean all"
branch_pattern: dev
script:
- ./autogen.sh
- ./configure --prefix=/tmp --disable-silent-rules
+17 -1
View File
@@ -3,6 +3,21 @@ Change Log
All notable changes to the project are documented in this file.
[v2.2.0][] - 2020-03-16
-----------------------
### Changes
- Add support for `systemf()`, formatted string `system()` replacement
- Add support for `fmkpath()`, formatted string `mkpath()`
- Add support for `fopenf()`, formatted string `fopen()` replacement
### Fixes
- Fix possible memory leak in `rsync()`, found by Coverity Scan
- Check return value of `fstat()` to prevent bogus destination file
times when using `copyfile()`, found by Coverity Scan
[v2.1.2][] - 2020-02-22
-----------------------
@@ -357,7 +372,8 @@ problems this may cause!
Initial extraction of frog DNA from [Finit][]. See [README][] for API details.
[UNRELEASED]: https://github.com/troglobit/libite/compare/v2.1.2...HEAD
[UNRELEASED]: https://github.com/troglobit/libite/compare/v2.2.0...HEAD
[v2.2.0]: https://github.com/troglobit/libite/compare/v2.1.2...v2.2.0
[v2.1.2]: https://github.com/troglobit/libite/compare/v2.1.1...v2.1.2
[v2.1.1]: https://github.com/troglobit/libite/compare/v2.1.0...v2.1.1
[v2.1.0]: https://github.com/troglobit/libite/compare/v2.0.2...v2.1.0
-6
View File
@@ -18,9 +18,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Note: Much of the code in libite (-lite) is written by Claudio Matsuoka
for Finit and released under the MIT/X11 license. Joachim Nilsson
later improved on the Finit code base and included pieces of
software released under the ISC and BSD licenses. See each
respective file for license details.
+36 -3
View File
@@ -1,7 +1,6 @@
-lite | Frog DNA, basically
===========================
[![Travis Status][]][Travis]
[![Travis Status][]][Travis] [![Coverity Status]][Coverity Scan]
Table of Contents
-----------------
@@ -12,7 +11,7 @@ Table of Contents
* [Generic Functions](#generic-functions)
* [OpenBSD Functions](#openbsd-functions)
* [Build & Install](#origin--references)
* [TODO](#todo)
* [Origin & References](#origin--references)
> **NOTE:** Incompatible changes in v2.0 compared to v1.x!
@@ -181,6 +180,15 @@ Generic Functions
Check for the existence of a directory, returns True(1) or False(0).
- `fopenf(mode, fmt, ...)`
Like `fopen()`, but takes a formatted string as argument. This
greatly simplifies operations that usually consist of composing a
filename from parts into a dynamic buffer before actually opening
the file.
> **Notice:** the swapped order of `pathname` and `mode`!
- `fsendfile(src, dst, len)`
Copy data between file streams, very similar to `fcopyfile()`, but
@@ -223,6 +231,12 @@ Generic Functions
Like `makepath()`, but also takes a `mode_t` permission mode argument.
- `fmkpath(mode, fmt, ...)`
Like `mkpath()`, but takes a formatted string as argument.
> **Notice:** the swapped order of `pathname` and `mode`!
- `movefile(src, dst)`
Like `copyfile()`, but renames `src` to `dst`, or recreates symlink
@@ -289,6 +303,12 @@ Generic Functions
Find matching string in an array of strings. Returns index in array
on match, or `-1` on error or not found.
`systemf(fmt, ...)`
Like `system()`, but takes a formatted string as argument. This
greatly simplifies operations that usually consist of composing a
command from parts into a dynamic buffer before calling it.
- `telnet_open(), telnet_close(), telnet_expect()`
Poor mans telnet expect in C. Opens connection to a Telnet service;
@@ -407,6 +427,14 @@ as a light weight utility library, these days NetBSD should also work.
to generate a `configure` script. It is a generated file and otherwise
only included in released tarballs.
Origin & References
-------------------
Much of the code in libite (-lite) is written by [Claudio Matsuoka][]
for [Finit][original finit] and released under the MIT/X11 license.
Joachim Nilsson later improved on the [Finit][] code base and included
pieces of software released under the ISC and BSD licenses. See each
respective file for license details.
[1]: https://github.com/troglobit/finit
[2]: http://www.openbsd.org/
@@ -419,3 +447,8 @@ only included in released tarballs.
[BSD]: https://en.wikipedia.org/wiki/BSD_licenses
[Travis]: https://travis-ci.org/troglobit/libite
[Travis Status]: https://travis-ci.org/troglobit/libite.png?branch=master
[Coverity Scan]: https://scan.coverity.com/projects/20602
[Coverity Status]: https://img.shields.io/coverity/scan/20602.svg
[Claudio Matsuoka]: https://github.com/cmatsuoka
[original finit]: http://helllabs.org/finit/
[Finit]: https://github.com/troglobit/finit
+2 -2
View File
@@ -1,4 +1,4 @@
AC_INIT(libite, 2.1.2, https://github.com/troglobit/libite/issues)
AC_INIT(libite, 2.2.0, https://github.com/troglobit/libite/issues)
AC_CONFIG_AUX_DIR(aux)
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
AM_SILENT_RULES([yes])
@@ -10,7 +10,7 @@ AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AC_PROG_INSTALL
AM_PROG_AR
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
LT_INIT
AC_OUTPUT
+13
View File
@@ -1,3 +1,16 @@
libite (2.2.0) unstable; urgency=medium
* New functions:
- systemf(), formatted string system() replacement
- fmkpath(), formatted string mkpath() replacement
- fopenf(), formatted string fopen() replacement
* Fixes
- possible memory leak in rsync()
- Check return value of fstat() to prevent bogus destination file
times when using copyfile()
-- Joachim Nilsson <troglobit@gmail.com> Mon, 16 Mar 2020 15:42:02 +0100
libite (2.1.2) stable; urgency=high
* Fix upgrade of base package, new library name to match SONAME
+1 -1
View File
@@ -1,7 +1,7 @@
Source: libite
Priority: optional
Maintainer: Joachim Nilsson <troglobit@gmail.com>
Build-Depends: debhelper (>= 10)
Build-Depends: debhelper (>= 10), libtool
Standards-Version: 4.3.0
Section: libs
Homepage: https://github.com/troglobit/libite/
+3
View File
@@ -9,6 +9,8 @@ libite.so.5 libite5 #MINVER#
fexist@Base 2.0.0
fgetint@Base 2.0.0
fisdir@Base 2.0.0
fmkpath@Base 2.2.0
fopenf@Base 2.2.0
fparseln@Base 2.0.0
fsendfile@Base 2.0.0
ifconfig@Base 2.0.0
@@ -35,6 +37,7 @@ libite.so.5 libite5 #MINVER#
strmatch@Base 2.1.0
strnmatch@Base 2.1.0
strtonum@Base 2.1.0
systemf@Base 2.2.0
telnet_close@Base 2.1.0
telnet_expect@Base 2.1.0
telnet_open@Base 2.1.0
+4 -3
View File
@@ -2,10 +2,10 @@ lib_LTLIBRARIES = libite.la
libite_la_CPPFLAGS = -D_GNU_SOURCE
libite_la_CFLAGS = -W -Wall -Wextra
libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 5:1:0
libite_la_LDFLAGS = $(AM_LDFLAGS) -version-info 6:0:1
libite_la_SOURCES = chomp.c copyfile.c \
conio.c conio.h \
dir.c \
dir.c fopenf.c \
fexist.c fisdir.c \
fparseln.c fsendfile.c \
ifconfig.c lfile.c \
@@ -14,7 +14,8 @@ libite_la_SOURCES = chomp.c copyfile.c \
reallocarray.c rsync.c \
strlcpy.c strlcat.c strtonum.c \
strdupa.h strndupa.h strnlen.h \
strmatch.c telnet.c tempfile.c \
strmatch.c systemf.c \
telnet.c tempfile.c \
yorn.c which.c \
lite.h strlite.h \
queue.h tree.h
+3 -1
View File
@@ -85,7 +85,9 @@ static void set_mtime(int in, int out)
struct stat st;
struct timespec tv[2];
fstat(in, &st);
if (fstat(in, &st))
return;
tv[0] = st.st_atim;
tv[1] = st.st_mtim;
futimens(out, tv);
+61
View File
@@ -0,0 +1,61 @@
/* Formatted fopen()
*
* Copyright (c) 2020 Joachim Nilsson <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
/**
* fopenf - Open a file based on the formatted string and optional arguments
* @mode: Last argument in optional list, if omitted EINVAL
* @fmt: Formatted string to be composed into a pathname
*
* This function is an extension to the fopen() family, lessening the burden
* of first having to compose the filename from parts in a seprate buffer.
*
* Returns:
* Upon successful completion fopenf() a FILE pointer. Otherwise, NULL
* is returned and errno is set to indicate the error.
*/
FILE *fopenf(const char *mode, const char *fmt, ...)
{
va_list ap;
FILE *fp = NULL;
char *file;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
va_start(ap, fmt);
file = alloca(len + 1);
if (file) {
vsnprintf(file, len + 1, fmt, ap);
fp = fopen(file, mode);
}
va_end(ap);
return fp;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+4
View File
@@ -65,6 +65,7 @@ char *fparseln (FILE *, size_t *, size_t *, const char[3], int);
int fexist (const char *file);
int fisdir (const char *path);
FILE *fopenf (const char *mode, const char *fmt, ...);
FILE *tempfile (void);
ssize_t copyfile (const char *src, const char *dst, int len, int opt);
int movefile (const char *src, const char *dst);
@@ -80,6 +81,7 @@ char *lfgetkey (lfile_t *lf, const char *key);
int lfgetint (lfile_t *lf, const char *key);
int fgetint (const char *file, const char *sep, const char *key);
int fmkpath (mode_t mode, const char *fmt, ...);
int mkpath (const char *dir, mode_t mode);
int makepath (const char *dir);
@@ -96,6 +98,8 @@ void *reallocarray(void *optr, size_t nmemb, size_t size);
void progress (int percent, int max_width);
void progress_simple(int percent);
int systemf (const char *fmt, ...);
sdbuf_t*telnet_open (int addr, short port);
int telnet_close (sdbuf_t *ctx);
int telnet_expect (sdbuf_t *ctx, char *script[], FILE *output);
+34
View File
@@ -17,6 +17,8 @@
#include <errno.h>
#include <libgen.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "lite.h"
@@ -46,6 +48,38 @@ int mkpath(const char *dir, mode_t mode)
return mkdir(dir, mode);
}
/**
* fmkpath - Formatted version of mkpath()
* @mode: A &mode_t mode to create directories with
* @fmt: Formatted string to be composed into a pathname
*
* Note:
* Notice the swapped arguments, compared to mkpath()!
*
* Returns:
* POSIX OK(0) on success, otherwise -1 with @errno set.
*/
int fmkpath(mode_t mode, const char *fmt, ...)
{
va_list ap;
char *path;
int len;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
path = alloca(len + 1);
if (!path)
return -1;
va_start(ap, fmt);
len = vsnprintf(path, len + 1, fmt, ap);
va_end(ap);
return mkpath(path, mode);
}
/**
* makepath - Create all components of the specified directory.
* @dir: Directory to create.
+7 -5
View File
@@ -107,20 +107,22 @@ int rsync(char *src, char *dst, int opt, int (*filter)(const char *file))
snprintf(source, sizeof(source), "%s%s%s", src, fisslashdir(src) ? "" : "/", files[i]);
if (fisdir(source)) {
char dst2[256];
struct stat st;
struct stat sb;
strcat(source, "/");
if (stat(source, &st))
return 1;
if (stat(source, &sb)) {
result++;
continue;
}
if (mdir(dst2, sizeof(dst2), dst, files[i], &st)) {
if (mdir(dst2, sizeof(dst2), dst, files[i], &sb)) {
result++;
continue;
}
rsync(source, dst2, opt, filter);
if (keep_mtim)
set_mtime(dst2, &st);
set_mtime(dst2, &sb);
continue; /* Next file/dir in @src to copy... */
}
+73
View File
@@ -0,0 +1,73 @@
/* Formatted system() which returns actual return status of command
*
* Copyright (c) 2020 Joachim Nilsson <troglobit@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
int systemf(const char *fmt, ...)
{
va_list ap;
char *cmd;
int len, status;
int rc = -1;
va_start(ap, fmt);
len = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);
va_start(ap, fmt);
cmd = alloca(++len);
if (!cmd) {
va_end(ap);
errno = ENOMEM;
return -1;
}
vsnprintf(cmd, len, fmt, ap);
va_end(ap);
status = system(cmd);
rc = WEXITSTATUS(status);
if (!WIFEXITED(status)) {
if (WIFSIGNALED(status) &&
(WTERMSIG(status) == SIGINT ||
WTERMSIG(status) == SIGQUIT)) {
errno = EINTR;
rc = -1;
} else if (!rc) {
/*
* Alert callee that command didn't complete
* successfully. Some programs don't change
* their exit code when signaled.
*/
rc = 1;
}
}
return rc;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+3
View File
@@ -1,11 +1,13 @@
*.o
*.log
*.trs
.deps/
chomp
copyfile
dir
fexist
fisdir
fopenf
fsendfile
lfile
makepath
@@ -15,6 +17,7 @@ progress
rsync
str
strmatch
systemf
tempfile
touch
tree
+2
View File
@@ -7,6 +7,7 @@ TESTS += copyfile
TESTS += dir
TESTS += fexist
TESTS += fisdir
TESTS += fopenf
TESTS += fsendfile
TESTS += lfile
TESTS += makepath
@@ -16,6 +17,7 @@ TESTS += progress
TESTS += rsync
TESTS += str
TESTS += strmatch
TESTS += systemf
TESTS += touch
TESTS += tempfile
TESTS += which
+18
View File
@@ -0,0 +1,18 @@
#include "check.h"
int main(void)
{
FILE *fp;
char *dir = "/tmp";
char *file = "__foo__";
fp = fopenf("w", "%s/%s", dir, file);
if (fp) {
fputs("foo", fp);
fclose(fp);
}
fail_unless(fexist("/tmp/__foo__"));
return 0;
}
+33 -11
View File
@@ -4,6 +4,8 @@
#include <stdlib.h>
#include "check.h"
#define BASEDIR "/tmp/libite-test"
int checkpath(const char *dir)
{
char tmp[256];
@@ -32,28 +34,48 @@ int test_makepath(const char *dir)
return ret;
}
int test_fmkpath(const char *subdir)
{
int ret;
ret = fmkpath(0755, "%s/%s", BASEDIR, subdir);
if (!ret) {
char tmp[256];
snprintf(tmp, sizeof(tmp), "%s/%s", BASEDIR, subdir);
ret = checkpath(tmp);
} else
perror("Failed");
return ret;
}
int main(void)
{
int i, ret = 0;
char *list[] = {
"/tmp/libite-test/tok/",
"/tmp/libite-test/tok2",
"/tmp/libite-test/ab",
"/tmp/libite-test/b",
"/tmp/libite-test/a/",
"/tmp/libite-test/a/b",
"/tmp/libite-test/a/c/",
BASEDIR "/tok/",
BASEDIR "/tok2",
BASEDIR "/ab",
BASEDIR "/b",
BASEDIR "/a/",
BASEDIR "/a/b",
BASEDIR "/a/c/",
NULL
};
printf("Testing makepath() ...\n");
mkdir("/tmp/libite-test", 0755);
mkdir(BASEDIR, 0755);
printf("PASS 1/2: makepath() ======================================\n");
for (i = 0; list[i] && !ret; i++)
ret |= test_makepath(list[i]);
printf("\nCleaning up ...\n");
system("rm -rf /tmp/libite-test");
printf("PASS 2/2: fmkpath() =======================================\n");
for (i = 0; list[i] && !ret; i++)
ret |= test_fmkpath(list[i] + strlen(BASEDIR) + 1);
printf("DONE: Cleaning up =========================================\n");
system("rm -rf " BASEDIR);
return ret;
}
+31
View File
@@ -0,0 +1,31 @@
#include <err.h>
#include "check.h"
int main(void)
{
struct { char *cmd; int rc; } list[] = {
{ "false", 1 },
{ "true", 0 },
{ "kill -9 $$", 1 },
{ "kill -QUIT $$", -1 },
{ "kill -INT $$", -1 }
};
for (size_t i = 0; i < NELEMS(list); i++) {
int rc;
rc = systemf("%s", list[i].cmd);
if (rc != list[i].rc)
err(rc, "Failed command %s", list[i].cmd);
}
return 0;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/