Skip to content

Commit

Permalink
[libnozzle] add api_nozzle_run_updown tests
Browse files Browse the repository at this point in the history
and cleanup lots of craft around related to the old testing method
for the same API

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Dec 14, 2018
1 parent 9221ff2 commit 7abdf88
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 313 deletions.
11 changes: 9 additions & 2 deletions libnozzle/libnozzle.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,23 @@ int nozzle_run_updown(const nozzle_t nozzle, uint8_t action, char **exec_string)

memset(command, 0, PATH_MAX);

snprintf(command, PATH_MAX, "%s%s/%s", nozzle->updownpath, action_str, nozzle->name);
snprintf(command, PATH_MAX, "%s/%s/%s", nozzle->updownpath, action_str, nozzle->name);

err = stat(command, &sb);
if (err) {
savederrno = errno;
goto out_clean;
}

/*
* clear errno from previous calls as there is no errno
* returned from execute_bin_sh_command
*/
savederrno = 0;
err = execute_bin_sh_command(command, exec_string);
savederrno = errno;
if (err) {
err = -2;
}

out_clean:
pthread_mutex_unlock(&config_mutex);
Expand Down
3 changes: 2 additions & 1 deletion libnozzle/libnozzle.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ int nozzle_close(nozzle_t nozzle);
*
* @return
* 0 on success
* -1 on error and errno is set.
* -1 on error and errno is set (sanity checks and internal calls.
* -2 on error from executing the shell scripts, and no errno is set.
*/

int nozzle_run_updown(const nozzle_t nozzle, uint8_t action, char **exec_string);
Expand Down
13 changes: 9 additions & 4 deletions libnozzle/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ MAINTAINERCLEANFILES = Makefile.in
include $(top_srcdir)/build-aux/check.mk

EXTRA_DIST = \
tap_updown_bad \
tap_updown_good \
nozzle_run_updown_exit_true \
nozzle_run_updown_exit_false \
api-test-coverage

noinst_HEADERS = \
Expand All @@ -31,7 +31,8 @@ api_checks = \
api_nozzle_set_mac_test \
api_nozzle_get_handle_by_name_test \
api_nozzle_get_name_by_handle_test \
api_nozzle_get_fd_test
api_nozzle_get_fd_test \
api_nozzle_run_updown_test

int_checks = \
int_execute_bin_sh_command_test \
Expand Down Expand Up @@ -61,7 +62,7 @@ check-api-test-coverage:
chmod u+x $(top_srcdir)/libnozzle/tests/api-test-coverage
$(top_srcdir)/libnozzle/tests/api-test-coverage $(top_srcdir) $(top_builddir)

AM_CPPFLAGS = -I$(top_srcdir)/libnozzle -DABSBUILDDIR=\"$(abs_builddir)\"
AM_CPPFLAGS = -I$(top_srcdir)/libnozzle -DABSBUILDDIR=\"$(abs_builddir)\" -DABSSRCDIR=\"$(abs_srcdir)\"
AM_CFLAGS += $(PTHREAD_CFLAGS) $(libnl_CFLAGS)
LIBS += $(top_builddir)/libnozzle/libnozzle.la $(PTHREAD_LIBS) $(libnl_LIBS)

Expand Down Expand Up @@ -101,6 +102,10 @@ api_nozzle_get_name_by_handle_test_SOURCES = api_nozzle_get_name_by_handle.c \
api_nozzle_get_fd_test_SOURCES = api_nozzle_get_fd.c \
test-common.c

api_nozzle_run_updown_test_SOURCES = api_nozzle_run_updown.c \
test-common.c \
../internals.c

int_execute_bin_sh_command_test_SOURCES = int_execute_bin_sh_command.c \
test-common.c \
../internals.c
Expand Down

0 comments on commit 7abdf88

Please sign in to comment.