-DBUILDDIR=\"$(abs_builddir)\" \
-DP11_KIT_FUTURE_UNSTABLE_API
-MEMCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=80 --quiet --trace-children=yes
+MEMCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=80 --quiet
LEAKCHECK_ENV = $(TEST_RUNNER) valgrind --error-exitcode=81 --quiet --leak-check=yes
}
}
if (i == ret) {
- fprintf (stderr, "# no suitable group, skipping test");
+ fprintf (stderr, "# no suitable group, skipping test\n");
return NULL;
}
$(NULL)
CHECK_PROGS = \
+ test-tests \
test-compat \
test-hash \
test-dict \
main (int argc,
char *argv[])
{
- p11_test (test_strndup, "/test/strndup");
- p11_test (test_getauxval, "/test/getauxval");
+ p11_test (test_strndup, "/compat/strndup");
+ p11_test (test_getauxval, "/compat/getauxval");
return p11_test_run (argc, argv);
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Red Hat Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * 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.
+ * * The names of contributors to this software may not be
+ * used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * 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 OWNER 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.
+ *
+ * Author: Stef Walter <stefw@redhat.com>
+ */
+
+#include "config.h"
+#include "test.h"
+
+#include <stdlib.h>
+
+static void
+test_success (void)
+{
+ /* Yup, nothing */
+}
+
+
+static void
+test_failure (void)
+{
+ if (getenv ("TEST_FAIL")) {
+ p11_test_fail (__FILE__, __LINE__, __FUNCTION__,
+ "Unconditional test failure due to TEST_FAIL environment variable");
+ }
+}
+
+static void
+test_memory (void)
+{
+ char *mem;
+
+ if (getenv ("TEST_FAIL")) {
+ mem = malloc (1);
+ free (mem);
+ *mem = 1;
+ }
+}
+
+
+static void
+test_leak (void)
+{
+ char *mem;
+
+ if (getenv ("TEST_FAIL")) {
+ mem = malloc (1);
+ *mem = 1;
+ }
+}
+
+int
+main (int argc,
+ char *argv[])
+{
+ p11_test (test_success, "/test/success");
+
+ if (getenv ("TEST_FAIL")) {
+ p11_test (test_failure, "/test/failure");
+ p11_test (test_memory, "/test/memory");
+ p11_test (test_leak, "/test/leak");
+ }
+
+ return p11_test_run (argc, argv);
+}
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([build/m4])
AC_CONFIG_AUX_DIR([build/aux])
-AM_INIT_AUTOMAKE([1.10 foreign])
+AM_INIT_AUTOMAKE([1.10 foreign serial-tests])
AM_SANITY_CHECK
AM_MAINTAINER_MODE([enable])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
{
if (stat (path, &st) < 0) {
error = errno;
- p11_message ("couldn't stat path: %s", path);
+ p11_message_err (error, "couldn't stat path: %s", path);
free (path);
break;
}
/* Fork during the initialization */
child = fork ();
if (child == 0) {
+ close (1);
nanosleep (&ts, NULL);
exit (66);
}
/* Fork during the initialization */
child = fork ();
if (child == 0) {
+ close (1);
nanosleep (&ts, NULL);
exit (66);
}
date = attr->pValue;
memset (&tm, 0, sizeof (tm));
- tm.tm_year = atoin ((char *)date->year, 4);
+ tm.tm_year = atoin ((char *)date->year, 4) - 1900;
tm.tm_mon = atoin ((char *)date->month, 2);
tm.tm_mday = atoin ((char *)date->day, 2);
{ CKA_INVALID },
};
- memcpy (&date, "20001010", sizeof (date));
+ memcpy (date.year, "2000", sizeof (date.year));
+ memcpy (date.month, "10", sizeof (date.month));
+ memcpy (date.day, "10", sizeof (date.day));
rv = p11_builder_build (test.builder, test.index, attrs, input, &extra);
assert_num_eq (CKR_OK, rv);
p11_message_quiet ();
- memcpy (&date, "AAAABBCC", sizeof (date));
+ memcpy (date.year, "AAAA", sizeof (date.year));
+ memcpy (date.month, "BB", sizeof (date.month));
+ memcpy (date.day, "CC", sizeof (date.day));
rv = p11_builder_build (test.builder, test.index, attrs, input, &extra);
assert_num_eq (CKR_ATTRIBUTE_VALUE_INVALID, rv);
- memcpy (&date, "20001580", sizeof (date));
+ memcpy (date.year, "2000", sizeof (date.year));
+ memcpy (date.month, "15", sizeof (date.month));
+ memcpy (date.day, "80", sizeof (date.day));
rv = p11_builder_build (test.builder, test.index, attrs, input, &extra);
assert_num_eq (CKR_ATTRIBUTE_VALUE_INVALID, rv);
struct stat sb;
if (stat (path, &sb) < 0) {
- if (errno == ENOENT) {
+ if (errno != ENOENT)
p11_message_err (errno, "couldn't stat path: %s", path);
- }
} else if (!S_ISDIR (sb.st_mode)) {
return loader_load_file (token, path, &sb);