* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
-#include <dirent.h>
-#include <stdio.h>
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/wait.h>
-#include "libkmod-util.h"
+#include <shared/util.h>
+
#include "testsuite.h"
static const char *ANSI_HIGHLIGHT_GREEN_ON = "\x1B[1;32m";
printf("\t-%c, --%s\n", *itr_short, itr->name);
}
-static void test_list(const struct test *tests[])
+static void test_list(const struct test *start, const struct test *stop)
{
- size_t i;
+ const struct test *t;
printf("Available tests:\n");
- for (i = 0; tests[i] != NULL; i++)
- printf("\t%s, %s\n", tests[i]->name, tests[i]->description);
+ for (t = start; t < stop; t++)
+ printf("\t%s, %s\n", t->name, t->description);
}
-int test_init(int argc, char *const argv[], const struct test *tests[])
+int test_init(const struct test *start, const struct test *stop,
+ int argc, char *const argv[])
{
progname = argv[0];
break;
switch (c) {
case 'l':
- test_list(tests);
+ test_list(start, stop);
return 0;
case 'h':
help();
return optind;
}
-const struct test *test_find(const struct test *tests[], const char *name)
+const struct test *test_find(const struct test *start,
+ const struct test *stop, const char *name)
{
- size_t i;
+ const struct test *t;
- for (i = 0; tests[i] != NULL; i++) {
- if (strcmp(tests[i]->name, name) == 0)
- return tests[i];
+ for (t = start; t < stop; t++) {
+ if (streq(t->name, name))
+ return t;
}
return NULL;
buf[r] = '\0';
bufmatch[r] = '\0';
- if (strcmp(buf, bufmatch) != 0) {
+ if (!streq(buf, bufmatch)) {
ERR("Outputs do not match on %s:\n",
fd_match == fd_matchout ? "stdout" : "stderr");
ERR("correct:\n%s\n", bufmatch);
pid = wait(&err);
if (pid == -1) {
ERR("error waitpid(): %m\n");
- return EXIT_FAILURE;
+ err = EXIT_FAILURE;
+ goto exit;
}
} while (!WIFEXITED(err) && !WIFSIGNALED(err));
} else if (WIFSIGNALED(err)) {
ERR("'%s' [%u] terminated by signal %d (%s)\n", t->name, pid,
WTERMSIG(err), strsignal(WTERMSIG(err)));
- return t->expected_fail ? EXIT_SUCCESS : EXIT_FAILURE;
+ err = t->expected_fail ? EXIT_SUCCESS : EXIT_FAILURE;
+ goto exit;
}
if (matchout)
}
}
+exit:
+ LOG("------\n");
return err;
}