Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F1842254
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
42 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/libnozzle/tests/api_nozzle_close.c b/libnozzle/tests/api_nozzle_close.c
index b954ec77..129b98c7 100644
--- a/libnozzle/tests/api_nozzle_close.c
+++ b/libnozzle/tests/api_nozzle_close.c
@@ -1,130 +1,130 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/socket.h>
#include <net/ethernet.h>
#ifdef KNET_LINUX
#include <linux/if_tun.h>
#include <netinet/ether.h>
#endif
#ifdef KNET_BSD
#include <net/if_dl.h>
#endif
#include "test-common.h"
char testipv4_1[IPBUFSIZE];
char testipv4_2[IPBUFSIZE];
char testipv6_1[IPBUFSIZE];
char testipv6_2[IPBUFSIZE];
static int test(void)
{
char device_name[2*IFNAMSIZ];
size_t size = IFNAMSIZ;
nozzle_t nozzle;
memset(device_name, 0, sizeof(device_name));
/*
* this test is duplicated from api_nozzle_open.c
*/
printf("Testing random nozzle interface:\n");
if (test_iface(device_name, size, NULL) < 0) {
printf("Unable to create random interface\n");
return -1;
}
printf("Testing ERROR conditions\n");
printf("Testing nozzle_close with NULL nozzle\n");
if ((nozzle_close(NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_close sanity checks\n");
return -1;
}
printf("Testing nozzle_close with random bytes nozzle pointer\n");
nozzle = (nozzle_t)0x1;
if ((nozzle_close(nozzle) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_close sanity checks\n");
return -1;
}
return 0;
}
/*
* requires running the test suite with valgrind
*/
static int check_nozzle_close_leak(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
printf("Testing close leak (needs valgrind)\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Adding ip: %s/24\n", testipv4_1);
err = nozzle_add_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
printf("Adding ip: %s/24\n", testipv4_2);
err = nozzle_add_ip(nozzle, testipv4_2, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
out_clean:
nozzle_close(nozzle);
return err;
}
int main(void)
{
need_root();
make_local_ips(testipv4_1, testipv4_2, testipv6_1, testipv6_2);
if (test() < 0)
return FAIL;
if (check_nozzle_close_leak() < 0)
return FAIL;
return 0;
}
diff --git a/libnozzle/tests/api_nozzle_get_fd.c b/libnozzle/tests/api_nozzle_get_fd.c
index 36481761..d32da6aa 100644
--- a/libnozzle/tests/api_nozzle_get_fd.c
+++ b/libnozzle/tests/api_nozzle_get_fd.c
@@ -1,77 +1,77 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <fcntl.h>
#include "test-common.h"
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
int fd;
printf("Testing get fd\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
fd = nozzle_get_fd(nozzle);
if (fd < 0) {
printf("Unable to get fd\n");
err = -1;
goto out_clean;
}
if (fcntl(fd, F_GETFD) < 0) {
printf("Unable to get valid fd\n");
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Passing empty struct to get_fd\n");
if (nozzle_get_fd(NULL) > 0) {
printf("Something is wrong in nozzle_get_fd sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_get_ips.c b/libnozzle/tests/api_nozzle_get_ips.c
index e29885e6..ce31cec5 100644
--- a/libnozzle/tests/api_nozzle_get_ips.c
+++ b/libnozzle/tests/api_nozzle_get_ips.c
@@ -1,182 +1,182 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/socket.h>
#include "test-common.h"
char testipv4_1[IPBUFSIZE];
char testipv4_2[IPBUFSIZE];
char testipv6_1[IPBUFSIZE];
char testipv6_2[IPBUFSIZE];
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err = 0;
nozzle_t nozzle;
struct nozzle_ip *ip_list = NULL, *ip_list_tmp = NULL;
int ip_list_entries = 0, ipv4_list_entries = 0, ipv6_list_entries = 0;
printf("Testing get ips\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Testing error conditions\n");
printf("Testing invalid nozzle\n");
err = nozzle_get_ips(NULL, &ip_list);
if ((!err) || (errno != EINVAL)) {
printf("nozzle_get_ips accepted invalid nozzle\n");
err = -1;
goto out_clean;
}
printf("Testing invalid ip list\n");
err = nozzle_get_ips(nozzle, NULL);
if ((!err) || (errno != EINVAL)) {
printf("nozzle_get_ips accepted invalid ip list\n");
err = -1;
goto out_clean;
}
printf("Adding ip: %s/24\n", testipv4_1);
err = nozzle_add_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err = -1;
goto out_clean;
}
printf("Adding ip: %s/24\n", testipv4_2);
err = nozzle_add_ip(nozzle, testipv4_2, "24");
if (err < 0) {
printf("Unable to assign IP address\n");
err = -1;
goto out_clean;
}
printf("Adding ip: %s/64\n", testipv6_1);
err = nozzle_add_ip(nozzle, testipv6_1, "64");
if (err < 0) {
printf("Unable to assign IP address\n");
err = -1;
goto out_clean;
}
printf("Adding ip: %s/64\n", testipv6_2);
err = nozzle_add_ip(nozzle, testipv6_2, "64");
if (err < 0) {
printf("Unable to assign IP address\n");
err = -1;
goto out_clean;
}
printf("Get ip list from libnozzle:\n");
if (nozzle_get_ips(nozzle, &ip_list) < 0) {
printf("Not enough mem?\n");
err = -1;
goto out_clean;
}
ip_list_tmp = ip_list;
ip_list_entries = 0;
while(ip_list_tmp) {
ip_list_entries++;
if (ip_list_tmp->domain == AF_INET) {
ipv4_list_entries++;
} else {
ipv6_list_entries++;
}
printf("Found IP %s %s in libnozzle db\n", ip_list_tmp->ipaddr, ip_list_tmp->prefix);
ip_list_tmp = ip_list_tmp->next;
}
if ((ip_list_entries != 4) ||
(ipv4_list_entries != 2) ||
(ipv6_list_entries != 2)) {
printf("Didn't get enough ip back from libnozzle?\n");
err = -1;
goto out_clean;
}
printf("Deleting ip: %s/24\n", testipv4_1);
err = nozzle_del_ip(nozzle, testipv4_1, "24");
if (err < 0) {
printf("Unable to delete IP address\n");
err = -1;
goto out_clean;
}
printf("Deleting ip: %s/24\n", testipv4_2);
err = nozzle_del_ip(nozzle, testipv4_2, "24");
if (err < 0) {
printf("Unable to delete IP address\n");
err = -1;
goto out_clean;
}
printf("Deleting ip: %s/64\n", testipv6_1);
err = nozzle_del_ip(nozzle, testipv6_1, "64");
if (err) {
printf("Unable to delete IP address\n");
err = -1;
goto out_clean;
}
printf("Deleting ip: %s/64\n", testipv6_2);
err = nozzle_del_ip(nozzle, testipv6_2, "64");
if (err) {
printf("Unable to delete IP address\n");
err = -1;
goto out_clean;
}
out_clean:
nozzle_close(nozzle);
return err;
}
int main(void)
{
need_root();
make_local_ips(testipv4_1, testipv4_2, testipv6_1, testipv6_2);
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_get_mac.c b/libnozzle/tests/api_nozzle_get_mac.c
index 9fc878ea..81f31427 100644
--- a/libnozzle/tests/api_nozzle_get_mac.c
+++ b/libnozzle/tests/api_nozzle_get_mac.c
@@ -1,130 +1,130 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/socket.h>
#include <net/ethernet.h>
#ifdef KNET_LINUX
#include <linux/if_tun.h>
#include <netinet/ether.h>
#endif
#ifdef KNET_BSD
#include <net/if_dl.h>
#endif
#include "test-common.h"
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
char *current_mac = NULL, *temp_mac = NULL, *err_mac = NULL;
struct ether_addr *cur_mac, *tmp_mac;
printf("Testing get MAC\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Get current MAC\n");
if (nozzle_get_mac(nozzle, ¤t_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
printf("Current MAC: %s\n", current_mac);
printf("Setting MAC: 00:01:01:01:01:01\n");
if (nozzle_set_mac(nozzle, "00:01:01:01:01:01") < 0) {
printf("Unable to set current MAC address.\n");
err = -1;
goto out_clean;
}
if (nozzle_get_mac(nozzle, &temp_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
printf("Current MAC: %s\n", temp_mac);
cur_mac = ether_aton(current_mac);
tmp_mac = ether_aton(temp_mac);
printf("Comparing MAC addresses\n");
if (memcmp(cur_mac, tmp_mac, sizeof(struct ether_addr))) {
printf("Mac addresses are not the same?!\n");
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Pass NULL to get_mac (pass1)\n");
errno = 0;
if ((nozzle_get_mac(NULL, &err_mac) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_get_mac sanity checks\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to get_mac (pass2)\n");
errno = 0;
if ((nozzle_get_mac(nozzle, NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_get_mac sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (err_mac) {
printf("Something managed to set err_mac!\n");
err = -1;
free(err_mac);
}
if (current_mac)
free(current_mac);
if (temp_mac)
free(temp_mac);
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_get_mtu.c b/libnozzle/tests/api_nozzle_get_mtu.c
index 2c34ca39..2db1a527 100644
--- a/libnozzle/tests/api_nozzle_get_mtu.c
+++ b/libnozzle/tests/api_nozzle_get_mtu.c
@@ -1,98 +1,98 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include "test-common.h"
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
int current_mtu = 0;
int expected_mtu = 1500;
printf("Testing get MTU\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Comparing default MTU\n");
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu < 0) {
printf("Unable to get MTU\n");
err = -1;
goto out_clean;
}
if (current_mtu != expected_mtu) {
printf("current mtu [%d] does not match expected default [%d]\n", current_mtu, expected_mtu);
err = -1;
goto out_clean;
}
printf("Setting MTU to 9000\n");
expected_mtu = 9000;
if (nozzle_set_mtu(nozzle, expected_mtu) < 0) {
printf("Unable to set MTU to %d\n", expected_mtu);
err = -1;
goto out_clean;
}
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu < 0) {
printf("Unable to get MTU\n");
err = -1;
goto out_clean;
}
if (current_mtu != expected_mtu) {
printf("current mtu [%d] does not match expected value [%d]\n", current_mtu, expected_mtu);
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Passing empty struct to get_mtu\n");
if (nozzle_get_mtu(NULL) > 0) {
printf("Something is wrong in nozzle_get_mtu sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_run_updown.c b/libnozzle/tests/api_nozzle_run_updown.c
index 89bf9095..ad81c457 100644
--- a/libnozzle/tests/api_nozzle_run_updown.c
+++ b/libnozzle/tests/api_nozzle_run_updown.c
@@ -1,401 +1,401 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "test-common.h"
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle = NULL;
char *error_string = NULL;
char *tmpdir = NULL;
char tmpdirsrc[PATH_MAX];
char tmpstr[PATH_MAX*2];
char srcfile[PATH_MAX];
char dstfile[PATH_MAX];
/*
* create a tmp dir for storing up/down scripts.
* we cannot create symlinks src dir
*/
strcpy(tmpdirsrc, ABSBUILDDIR "/nozzle_test_XXXXXX");
tmpdir = mkdtemp(tmpdirsrc);
if (!tmpdir) {
printf("Unable to create temporary directory %s for testing: %s\n", tmpdirsrc, strerror(errno));
return -1;
}
printf("Created temporary test dir: %s\n", tmpdir);
printf("Populating test dir...\n");
snprintf(tmpstr, sizeof(tmpstr) - 1, "%s/pre-up.d", tmpdir);
if (mkdir(tmpstr, 0700) < 0) {
printf("Unable to create %s/pre-up.d: %s", tmpdir, strerror(errno));
err = -1;
goto out_clean;
}
snprintf(tmpstr, sizeof(tmpstr) - 1, "%s/up.d", tmpdir);
if (mkdir(tmpstr, 0700) < 0) {
printf("Unable to create %s/up.d: %s", tmpdir, strerror(errno));
err = -1;
goto out_clean;
}
snprintf(tmpstr, sizeof(tmpstr) - 1, "%s/down.d", tmpdir);
if (mkdir(tmpstr, 0700) < 0) {
printf("Unable to create %s/down.d: %s", tmpdir, strerror(errno));
err = -1;
goto out_clean;
}
snprintf(tmpstr, sizeof(tmpstr) - 1, "%s/post-down.d", tmpdir);
if (mkdir(tmpstr, 0700) < 0) {
printf("Unable to create %s/post-down.d: %s", tmpdir, strerror(errno));
err = -1;
goto out_clean;
}
printf("Testing error conditions\n");
printf("Init nozzle device with no path\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
err = -1;
goto out_clean;
}
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN, &error_string);
if ((!err) || (errno != EINVAL)) {
printf("nozzle_run_updown sanity check failed\n");
err = -1;
goto out_clean;
}
nozzle_close(nozzle);
printf("Init nozzle device with path\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, tmpdir);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
err = -1;
goto out_clean;
}
printf("Testing invalid nozzle handle\n");
err = nozzle_run_updown(NULL, NOZZLE_POSTDOWN, &error_string);
if ((!err) || (errno != EINVAL)) {
printf("nozzle_run_updown sanity check failed\n");
err = -1;
goto out_clean;
}
printf("Testing invalid action\n");
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN + 1, &error_string);
if ((!err) || (errno != EINVAL)) {
printf("nozzle_run_updown sanity check failed\n");
err = -1;
goto out_clean;
}
printf("Testing invalid error string\n");
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN + 1, NULL);
if ((!err) || (errno != EINVAL)) {
printf("nozzle_run_updown sanity check failed\n");
err = -1;
goto out_clean;
}
printf("Testing interface pre-up/up/down/post-down (no scripts installed)\n");
err = nozzle_run_updown(nozzle, NOZZLE_PREUP, &error_string);
if (!err) {
printf("nozzle_run_updown failed to detect lack of script in pre-up.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_UP, &error_string);
if (!err) {
printf("nozzle_run_updown failed to detect lack of script in up.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_DOWN, &error_string);
if (!err) {
printf("nozzle_run_updown failed to detect lack of script in down.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN, &error_string);
if (!err) {
printf("nozzle_run_updown failed to detect lack of script in post-down.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
printf("Populating test dir with fail scripts\n");
snprintf(srcfile, sizeof(srcfile) - 1, "%s/nozzle_run_updown_exit_false", ABSSRCDIR);
snprintf(dstfile, sizeof(dstfile) - 1, "%s/pre-up.d/%s", tmpdir, device_name);
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
snprintf(dstfile, sizeof(dstfile) - 1, "%s/up.d/%s", tmpdir, device_name);
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
snprintf(dstfile, sizeof(dstfile) - 1, "%s/down.d/%s", tmpdir, device_name);
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
snprintf(dstfile, sizeof(dstfile) - 1, "%s/post-down.d/%s", tmpdir, device_name);
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
printf("Testing interface pre-up/up/down/post-down (FAIL scripts installed)\n");
err = nozzle_run_updown(nozzle, NOZZLE_PREUP, &error_string);
if (err != -2) {
printf("nozzle_run_updown failed to detect script failure in pre-up.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_UP, &error_string);
if (err != -2) {
printf("nozzle_run_updown failed to detect script failure in up.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_DOWN, &error_string);
if (err != -2) {
printf("nozzle_run_updown failed to detect script failure in down.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN, &error_string);
if (err != -2) {
printf("nozzle_run_updown failed to detect script failure in post-down.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
printf("Populating test dir with true scripts\n");
snprintf(srcfile, sizeof(srcfile) - 1, "%s/nozzle_run_updown_exit_true", ABSSRCDIR);
snprintf(dstfile, sizeof(dstfile) - 1, "%s/pre-up.d/%s", tmpdir, device_name);
if (unlink(dstfile) < 0) {
printf("unable to remove old symlink\n");
err = -1;
goto out_clean;
}
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
snprintf(dstfile, sizeof(dstfile) - 1, "%s/up.d/%s", tmpdir, device_name);
if (unlink(dstfile) < 0) {
printf("unable to remove old symlink\n");
err = -1;
goto out_clean;
}
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
snprintf(dstfile, sizeof(dstfile) - 1, "%s/down.d/%s", tmpdir, device_name);
if (unlink(dstfile) < 0) {
printf("unable to remove old symlink\n");
err = -1;
goto out_clean;
}
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
snprintf(dstfile, sizeof(dstfile) - 1, "%s/post-down.d/%s", tmpdir, device_name);
if (unlink(dstfile) < 0) {
printf("unable to remove old symlink\n");
err = -1;
goto out_clean;
}
if (link(srcfile, dstfile) < 0) {
printf("unable to create symlink\n");
err = -1;
goto out_clean;
}
printf("Testing interface pre-up/up/down/post-down (TRUE scripts installed)\n");
err = nozzle_run_updown(nozzle, NOZZLE_PREUP, &error_string);
if (err) {
printf("nozzle_run_updown failed to execute true script in pre-up.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_UP, &error_string);
if (err) {
printf("nozzle_run_updown failed to execute true script in up.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_DOWN, &error_string);
if (err) {
printf("nozzle_run_updown failed to execite true script in down.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
err = nozzle_run_updown(nozzle, NOZZLE_POSTDOWN, &error_string);
if (err) {
printf("nozzle_run_updown failed to execute true script in post-down.d\n");
err = -1;
goto out_clean;
} else {
if (error_string) {
free(error_string);
error_string = NULL;
}
}
out_clean:
if (tmpdir) {
snprintf(tmpstr, sizeof(tmpstr) - 1, "rm -rf %s", tmpdir);
printf("Removing temporary dir: %s\n", tmpstr);
err = execute_bin_sh_command(tmpstr, &error_string);
if (err) {
printf("Error removing directory: %s\n", error_string);
}
if (error_string) {
free(error_string);
}
}
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_set_down.c b/libnozzle/tests/api_nozzle_set_down.c
index 3921772b..f477a4b2 100644
--- a/libnozzle/tests/api_nozzle_set_down.c
+++ b/libnozzle/tests/api_nozzle_set_down.c
@@ -1,126 +1,126 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include "test-common.h"
static int test(void)
{
char verifycmd[1024];
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
char *error_string = NULL;
printf("Testing interface down\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Put the interface up\n");
err = nozzle_set_up(nozzle);
if (err < 0) {
printf("Unable to set interface up\n");
err = -1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q UP", nozzle->name);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q UP", nozzle->name);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err < 0) {
printf("Unable to verify inteface UP\n");
err = -1;
goto out_clean;
}
printf("Put the interface down\n");
err = nozzle_set_down(nozzle);
if (err < 0) {
printf("Unable to put the interface down\n");
err = -1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q UP", nozzle->name);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q UP", nozzle->name);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Unable to verify inteface DOWN\n");
err = -1;
goto out_clean;
}
printf("Try to DOWN the same interface twice\n");
if (nozzle_set_down(nozzle) < 0) {
printf("Interface was already DOWN, spurious error received from nozzle_set_down\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to nozzle set_down\n");
errno = 0;
if ((nozzle_set_down(NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_down sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
nozzle_close(nozzle);
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_set_mac.c b/libnozzle/tests/api_nozzle_set_mac.c
index 25249dc7..d7ea405d 100644
--- a/libnozzle/tests/api_nozzle_set_mac.c
+++ b/libnozzle/tests/api_nozzle_set_mac.c
@@ -1,162 +1,162 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/socket.h>
#include <net/ethernet.h>
#ifdef KNET_LINUX
#include <linux/if_tun.h>
#include <netinet/ether.h>
#endif
#ifdef KNET_BSD
#include <net/if_dl.h>
#endif
#include "test-common.h"
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
char *original_mac = NULL, *current_mac = NULL, *temp_mac = NULL, *err_mac = NULL;
struct ether_addr *orig_mac, *cur_mac, *tmp_mac;
printf("Testing set MAC\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Get current MAC\n");
if (nozzle_get_mac(nozzle, &original_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
orig_mac = ether_aton(original_mac);
if (nozzle_get_mac(nozzle, ¤t_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
printf("Current MAC: %s\n", current_mac);
printf("Setting MAC: 00:01:01:01:01:01\n");
if (nozzle_set_mac(nozzle, "00:01:01:01:01:01") < 0) {
printf("Unable to set current MAC address.\n");
err = -1;
goto out_clean;
}
if (nozzle_get_mac(nozzle, &temp_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
printf("Current MAC: %s\n", temp_mac);
cur_mac = ether_aton(current_mac);
tmp_mac = ether_aton(temp_mac);
printf("Comparing MAC addresses\n");
if (memcmp(cur_mac, tmp_mac, sizeof(struct ether_addr))) {
printf("Mac addresses are not the same?!\n");
err = -1;
goto out_clean;
}
printf("Testing reset_mac\n");
if (nozzle_reset_mac(nozzle) < 0) {
printf("Unable to reset mac address\n");
err = -1;
goto out_clean;
}
if (current_mac)
free(current_mac);
if (nozzle_get_mac(nozzle, ¤t_mac) < 0) {
printf("Unable to get current MAC address.\n");
err = -1;
goto out_clean;
}
cur_mac = ether_aton(current_mac);
if (memcmp(cur_mac, orig_mac, sizeof(struct ether_addr))) {
printf("Mac addresses are not the same?!\n");
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Pass NULL to set_mac (pass1)\n");
errno = 0;
if ((nozzle_set_mac(nozzle, NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_mac sanity checks\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to set_mac (pass2)\n");
errno = 0;
if ((nozzle_set_mac(NULL, err_mac) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_mac sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (err_mac) {
printf("Something managed to set err_mac!\n");
err = -1;
free(err_mac);
}
if (current_mac)
free(current_mac);
if (temp_mac)
free(temp_mac);
if (original_mac)
free(original_mac);
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_set_mtu.c b/libnozzle/tests/api_nozzle_set_mtu.c
index 510b2d46..b26df345 100644
--- a/libnozzle/tests/api_nozzle_set_mtu.c
+++ b/libnozzle/tests/api_nozzle_set_mtu.c
@@ -1,297 +1,297 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include "test-common.h"
char testipv4_1[IPBUFSIZE];
char testipv4_2[IPBUFSIZE];
char testipv6_1[IPBUFSIZE];
char testipv6_2[IPBUFSIZE];
static int test(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
int current_mtu = 0;
int expected_mtu = 1500;
printf("Testing set MTU\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Comparing default MTU\n");
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu < 0) {
printf("Unable to get MTU\n");
err = -1;
goto out_clean;
}
if (current_mtu != expected_mtu) {
printf("current mtu [%d] does not match expected default [%d]\n", current_mtu, expected_mtu);
err = -1;
goto out_clean;
}
printf("Setting MTU to 9000\n");
expected_mtu = 9000;
if (nozzle_set_mtu(nozzle, expected_mtu) < 0) {
printf("Unable to set MTU to %d\n", expected_mtu);
err = -1;
goto out_clean;
}
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu < 0) {
printf("Unable to get MTU\n");
err = -1;
goto out_clean;
}
if (current_mtu != expected_mtu) {
printf("current mtu [%d] does not match expected value [%d]\n", current_mtu, expected_mtu);
err = -1;
goto out_clean;
}
printf("Restoring MTU to default\n");
expected_mtu = 1500;
if (nozzle_reset_mtu(nozzle) < 0) {
printf("Unable to reset mtu\n");
err = -1;
goto out_clean;
}
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu < 0) {
printf("Unable to get MTU\n");
err = -1;
goto out_clean;
}
if (current_mtu != expected_mtu) {
printf("current mtu [%d] does not match expected value [%d]\n", current_mtu, expected_mtu);
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("Passing empty struct to set_mtu\n");
if (nozzle_set_mtu(NULL, 1500) == 0) {
printf("Something is wrong in nozzle_set_mtu sanity checks\n");
err = -1;
goto out_clean;
}
printf("Passing 0 mtu to set_mtu\n");
if (nozzle_set_mtu(nozzle, 0) == 0) {
printf("Something is wrong in nozzle_set_mtu sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
static int test_ipv6(void)
{
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
char verifycmd[2048];
int err=0;
nozzle_t nozzle;
char *error_string = NULL;
int current_mtu = 0;
printf("Testing get/set MTU with IPv6 address\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Adding ip: %s/64\n", testipv6_1);
err = nozzle_add_ip(nozzle, testipv6_1, "64");
if (err) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Setting MTU to 1200\n");
if (nozzle_set_mtu(nozzle, 1200) < 0) {
printf("Unable to set MTU to 1200\n");
err = -1;
goto out_clean;
}
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
#ifdef KNET_LINUX
if (!err) {
#endif
#ifdef KNET_BSD
if (err) {
#endif
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Adding ip: %s/64\n", testipv6_2);
err = nozzle_add_ip(nozzle, testipv6_2, "64");
if (err < 0) {
printf("Unable to assign IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_2);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_2);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
printf("Restoring MTU to default\n");
if (nozzle_reset_mtu(nozzle) < 0) {
printf("Unable to reset mtu\n");
err = -1;
goto out_clean;
}
current_mtu = nozzle_get_mtu(nozzle);
if (current_mtu != 1500) {
printf("current mtu [%d] does not match expected value [1500]\n", current_mtu);
err = -1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_1);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_1);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q %s/64", nozzle->name, testipv6_2);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q %s", nozzle->name, testipv6_2);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to verify IP address\n");
err=-1;
goto out_clean;
}
out_clean:
if (nozzle) {
nozzle_close(nozzle);
}
return err;
}
int main(void)
{
need_root();
make_local_ips(testipv4_1, testipv4_2, testipv6_1, testipv6_2);
if (test() < 0)
return FAIL;
if (test_ipv6() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/api_nozzle_set_up.c b/libnozzle/tests/api_nozzle_set_up.c
index 258270d2..687e6b6b 100644
--- a/libnozzle/tests/api_nozzle_set_up.c
+++ b/libnozzle/tests/api_nozzle_set_up.c
@@ -1,100 +1,100 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/socket.h>
#include "test-common.h"
static int test(void)
{
char verifycmd[1024];
char device_name[IFNAMSIZ];
size_t size = IFNAMSIZ;
int err=0;
nozzle_t nozzle;
char *error_string = NULL;
printf("Testing interface up/down\n");
memset(device_name, 0, size);
nozzle = nozzle_open(device_name, size, NULL);
if (!nozzle) {
printf("Unable to init %s\n", device_name);
return -1;
}
printf("Put the interface up\n");
if (nozzle_set_up(nozzle) < 0) {
printf("Unable to set interface up\n");
err = -1;
goto out_clean;
}
memset(verifycmd, 0, sizeof(verifycmd));
snprintf(verifycmd, sizeof(verifycmd)-1,
#ifdef KNET_LINUX
"ip addr show dev %s | grep -q UP", nozzle->name);
#endif
#ifdef KNET_BSD
"ifconfig %s | grep -q UP", nozzle->name);
#endif
err = execute_bin_sh_command(verifycmd, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err < 0) {
printf("Unable to verify inteface UP\n");
err = -1;
goto out_clean;
}
printf("Test ERROR conditions\n");
printf("Try to UP the same interface twice\n");
if (nozzle_set_up(nozzle) < 0) {
printf("Interface was already UP, spurious error received from nozzle_set_up\n");
err = -1;
goto out_clean;
}
printf("Pass NULL to nozzle set_up\n");
errno = 0;
if ((nozzle_set_up(NULL) >= 0) || (errno != EINVAL)) {
printf("Something is wrong in nozzle_set_up sanity checks\n");
err = -1;
goto out_clean;
}
out_clean:
nozzle_set_down(nozzle);
nozzle_close(nozzle);
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
diff --git a/libnozzle/tests/int_execute_bin_sh_command.c b/libnozzle/tests/int_execute_bin_sh_command.c
index c5a7e5d4..a6a133ff 100644
--- a/libnozzle/tests/int_execute_bin_sh_command.c
+++ b/libnozzle/tests/int_execute_bin_sh_command.c
@@ -1,121 +1,121 @@
/*
- * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <sys/socket.h>
#include "test-common.h"
static int test(void)
{
int err = 0;
char *error_string = NULL;
printf("Testing execute_bin_sh_command\n");
printf("command true\n");
err = execute_bin_sh_command("true", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (err) {
printf("Unable to execute true ?!?!\n");
goto out_clean;
}
printf("command false\n");
err = execute_bin_sh_command("false", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Can we really execute false successfully?!?!\n");
err = -1;
goto out_clean;
}
printf("command that outputs to stdout (enforcing redirect)\n");
err = execute_bin_sh_command("grep -h 2>&1", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Can we really execute grep -h successfully?!?\n");
err = -1;
goto out_clean;
}
printf("command that outputs to stderr\n");
err = execute_bin_sh_command("grep -h", &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if (!err) {
printf("Can we really execute grep -h successfully?!?\n");
err = -1;
goto out_clean;
}
printf("Testing ERROR conditions\n");
printf("empty command\n");
err = execute_bin_sh_command(NULL, &error_string);
if (error_string) {
printf("Error string: %s\n", error_string);
free(error_string);
error_string = NULL;
}
if ((!err) || (errno != EINVAL)) {
printf("execute_bin_sh_command returned incorrect error or incorrect errno!\n");
err = -1;
goto out_clean;
}
printf("empty error\n");
err = execute_bin_sh_command("true", NULL);
if ((!err) || (errno != EINVAL)) {
printf("execute_bin_sh_command returned incorrect error or incorrect errno!\n");
err = -1;
goto out_clean;
}
err = 0;
out_clean:
return err;
}
int main(void)
{
need_root();
if (test() < 0)
return FAIL;
return PASS;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 2:46 PM (20 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1014322
Default Alt Text
(42 KB)
Attached To
Mode
rK kronosnet
Attached
Detach File
Event Timeline
Log In to Comment