|
|
562801 |
From d036dce0c804a6d91790dd8e6aa4f2ca08e703d9 Mon Sep 17 00:00:00 2001
|
|
|
562801 |
From: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
562801 |
Date: Tue, 29 Mar 2016 12:11:23 +0200
|
|
|
562801 |
Subject: [PATCH] testsuite: problem_data: add problem_data_reproducible
|
|
|
562801 |
testcase
|
|
|
562801 |
|
|
|
562801 |
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
|
|
|
562801 |
---
|
|
|
562801 |
tests/problem_data.at | 415 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
562801 |
1 file changed, 415 insertions(+)
|
|
|
562801 |
create mode 100644 tests/problem_data.at
|
|
|
562801 |
|
|
|
562801 |
diff --git a/tests/problem_data.at b/tests/problem_data.at
|
|
|
562801 |
new file mode 100644
|
|
|
562801 |
index 0000000..c4ee4de
|
|
|
562801 |
--- /dev/null
|
|
|
562801 |
+++ b/tests/problem_data.at
|
|
|
562801 |
@@ -0,0 +1,415 @@
|
|
|
562801 |
+# -*- Autotest -*-
|
|
|
562801 |
+
|
|
|
562801 |
+AT_BANNER([problem data])
|
|
|
562801 |
+
|
|
|
562801 |
+## ---------------- ##
|
|
|
562801 |
+## problem_data_add ##
|
|
|
562801 |
+## ---------------- ##
|
|
|
562801 |
+
|
|
|
562801 |
+AT_TESTFUN([problem_data_add],
|
|
|
562801 |
+[[
|
|
|
562801 |
+#include "problem_data.h"
|
|
|
562801 |
+#include "internal_libreport.h"
|
|
|
562801 |
+#include <assert.h>
|
|
|
562801 |
+
|
|
|
562801 |
+#define TEST_NAME "package"
|
|
|
562801 |
+#define TEST_CONTENTS "libreport"
|
|
|
562801 |
+#define TEST_FLAGS (CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE | CD_FLAG_UNIXTIME)
|
|
|
562801 |
+
|
|
|
562801 |
+int main(int argc, char **argv)
|
|
|
562801 |
+{
|
|
|
562801 |
+ g_verbose = 3;
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_t *data = problem_data_new();
|
|
|
562801 |
+ problem_data_add(data, TEST_NAME, TEST_CONTENTS, TEST_FLAGS);
|
|
|
562801 |
+
|
|
|
562801 |
+ struct problem_item *itm = problem_data_get_item_or_NULL(data, TEST_NAME);
|
|
|
562801 |
+
|
|
|
562801 |
+ assert(strcmp(itm->content, TEST_CONTENTS) == 0);
|
|
|
562801 |
+ assert(itm->flags == TEST_FLAGS);
|
|
|
562801 |
+ assert(itm->size == PROBLEM_ITEM_UNINITIALIZED_SIZE);
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_free(data);
|
|
|
562801 |
+
|
|
|
562801 |
+ return 0;
|
|
|
562801 |
+}
|
|
|
562801 |
+]])
|
|
|
562801 |
+
|
|
|
562801 |
+## -------------------- ##
|
|
|
562801 |
+## problem_data_add_ext ##
|
|
|
562801 |
+## -------------------- ##
|
|
|
562801 |
+
|
|
|
562801 |
+AT_TESTFUN([problem_data_add_ext],
|
|
|
562801 |
+[[
|
|
|
562801 |
+#include "problem_data.h"
|
|
|
562801 |
+#include "internal_libreport.h"
|
|
|
562801 |
+#include <assert.h>
|
|
|
562801 |
+
|
|
|
562801 |
+#define TEST_NAME "package"
|
|
|
562801 |
+#define TEST_CONTENTS "libreport"
|
|
|
562801 |
+#define TEST_FLAGS (CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE | CD_FLAG_UNIXTIME)
|
|
|
562801 |
+
|
|
|
562801 |
+int main(int argc, char **argv)
|
|
|
562801 |
+{
|
|
|
562801 |
+ g_verbose = 3;
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_t *data = problem_data_new();
|
|
|
562801 |
+ struct problem_item *itm = problem_data_add_ext(data, TEST_NAME, TEST_CONTENTS, TEST_FLAGS, strlen(TEST_CONTENTS));
|
|
|
562801 |
+
|
|
|
562801 |
+ struct problem_item *found = problem_data_get_item_or_NULL(data, TEST_NAME);
|
|
|
562801 |
+ assert(itm == found);
|
|
|
562801 |
+
|
|
|
562801 |
+ assert(strcmp(itm->content, TEST_CONTENTS) == 0);
|
|
|
562801 |
+ assert(itm->flags == TEST_FLAGS);
|
|
|
562801 |
+ assert(itm->size == strlen(TEST_CONTENTS));
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_free(data);
|
|
|
562801 |
+
|
|
|
562801 |
+ return 0;
|
|
|
562801 |
+}
|
|
|
562801 |
+]])
|
|
|
562801 |
+
|
|
|
562801 |
+## ---------------------- ##
|
|
|
562801 |
+## problem_item_get_size ##
|
|
|
562801 |
+## ---------------------- ##
|
|
|
562801 |
+
|
|
|
562801 |
+AT_TESTFUN([problem_item_get_size],
|
|
|
562801 |
+[[
|
|
|
562801 |
+#include "problem_data.h"
|
|
|
562801 |
+#include "internal_libreport.h"
|
|
|
562801 |
+#include <assert.h>
|
|
|
562801 |
+
|
|
|
562801 |
+int main(int argc, char **argv)
|
|
|
562801 |
+{
|
|
|
562801 |
+ g_verbose = 3;
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_t *data = problem_data_new();
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ struct problem_item *itm = problem_data_add_ext(data, "1", "foo", CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE, PROBLEM_ITEM_UNINITIALIZED_SIZE);
|
|
|
562801 |
+ const size_t old_size = strlen(itm->content);
|
|
|
562801 |
+ {
|
|
|
562801 |
+ size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
|
|
|
562801 |
+ assert(problem_item_get_size(itm, ¤t_size) == 0);
|
|
|
562801 |
+ assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
|
|
|
562801 |
+ assert(current_size == old_size);
|
|
|
562801 |
+ }
|
|
|
562801 |
+ {
|
|
|
562801 |
+ free(itm->content);
|
|
|
562801 |
+ itm->content = NULL;
|
|
|
562801 |
+ size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
|
|
|
562801 |
+ assert(problem_item_get_size(itm, ¤t_size) == 0);
|
|
|
562801 |
+ assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
|
|
|
562801 |
+ assert(current_size == old_size);
|
|
|
562801 |
+ }
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ char flnm[] = "/tmp/libreport.unittest.XXXXXXX";
|
|
|
562801 |
+ int flds = mkstemp(flnm);
|
|
|
562801 |
+ assert(flds >= 0);
|
|
|
562801 |
+ /* sizeof(flnm) is strlen + '\0' */
|
|
|
562801 |
+ assert(write(flds, flnm, strlen(flnm)) == strlen(flnm));
|
|
|
562801 |
+ fsync(flds);
|
|
|
562801 |
+
|
|
|
562801 |
+ struct stat buf;
|
|
|
562801 |
+ assert(fstat(flds, &buf) == 0);
|
|
|
562801 |
+ assert(buf.st_size != 0);
|
|
|
562801 |
+ size_t old_size = buf.st_size;
|
|
|
562801 |
+
|
|
|
562801 |
+ struct problem_item *itm = problem_data_add_ext(data, "2", flnm, CD_FLAG_BIN, PROBLEM_ITEM_UNINITIALIZED_SIZE);
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
|
|
|
562801 |
+ assert(problem_item_get_size(itm, ¤t_size) == 0);
|
|
|
562801 |
+ assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
|
|
|
562801 |
+ assert(current_size == old_size);
|
|
|
562801 |
+ }
|
|
|
562801 |
+ {
|
|
|
562801 |
+ close(flds);
|
|
|
562801 |
+ unlink(flnm);
|
|
|
562801 |
+ assert(stat(flnm, &buf) != 0);
|
|
|
562801 |
+ size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
|
|
|
562801 |
+ assert(problem_item_get_size(itm, ¤t_size) == 0);
|
|
|
562801 |
+ assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
|
|
|
562801 |
+ assert(current_size == old_size);
|
|
|
562801 |
+ }
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_free(data);
|
|
|
562801 |
+
|
|
|
562801 |
+ return 0;
|
|
|
562801 |
+}
|
|
|
562801 |
+]])
|
|
|
562801 |
+
|
|
|
562801 |
+## ------------------------------- ##
|
|
|
562801 |
+## problem_data_load_from_dump_dir ##
|
|
|
562801 |
+## ------------------------------- ##
|
|
|
562801 |
+
|
|
|
562801 |
+AT_TESTFUN([problem_data_load_from_dump_dir],
|
|
|
562801 |
+[[
|
|
|
562801 |
+#include "problem_data.h"
|
|
|
562801 |
+#include "internal_libreport.h"
|
|
|
562801 |
+#include <assert.h>
|
|
|
562801 |
+
|
|
|
562801 |
+int main(int argc, char **argv)
|
|
|
562801 |
+{
|
|
|
562801 |
+ g_verbose = 3;
|
|
|
562801 |
+
|
|
|
562801 |
+ char template[] = "/tmp/XXXXXX";
|
|
|
562801 |
+
|
|
|
562801 |
+ if (mkdtemp(template) == NULL) {
|
|
|
562801 |
+ perror("mkdtemp()");
|
|
|
562801 |
+ return EXIT_FAILURE;
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ printf("Dump dir path: %s\n", template);
|
|
|
562801 |
+
|
|
|
562801 |
+ struct dump_dir *dd = dd_create(template, (uid_t)-1, 0640);
|
|
|
562801 |
+ assert(dd != NULL || !"Cannot create new dump directory");
|
|
|
562801 |
+
|
|
|
562801 |
+ /* dd_create_basic_files() should create these files:
|
|
|
562801 |
+ FILENAME_TIME, FILENAME_LAST_OCCURRENCE, FILENAME_UID, FILENAME_KERNEL,
|
|
|
562801 |
+ FILENAME_ARCHITECTURE, FILENAME_HOSTNAME, FILENAME_OS_INFO, FILENAME_OS_RELEASE
|
|
|
562801 |
+ */
|
|
|
562801 |
+ dd_create_basic_files(dd, geteuid(), NULL);
|
|
|
562801 |
+
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_TYPE, "attest");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_ANALYZER, "attest-problem_data");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_DUPHASH, "0123456789ABCDEF");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_UUID, "FEDCBA9876543210");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_USERNAME, "perhaps_tester");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PACKAGE, "1:attest-1.1-3.x86_64");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PKG_EPOCH, "1");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PKG_NAME, "attest");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PKG_VERSION, "1.1");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PKG_RELEASE, "3");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PKG_ARCH, "x86_64");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CMDLINE, "$TESTSUITE.DIR/$NUM/problem_data_load_from_dump_dir foo blah");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_EXECUTABLE, "$TESTSUITE.DIR/$NUM/problem_data_load_from_dump_dir");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_ROOTDIR, "/");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PWD, "$TESTSUITE.DIR");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PID, "12345");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_GLOBAL_PID, "12345");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_TID, "12345");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_COUNT, "1");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_REASON, "Unit testing problem_data_load_from_dump_dir");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_COMMENT, "Random comment");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_BACKTRACE, "Pseudo-backtrace");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_OPEN_FDS, "Opened FDs");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_MAPS, "/proc/[pid]/maps");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_SMAPS, "/proc/[pid]/smaps");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_ENVIRON, "/proc/[pid]/environ");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_LIMITS, "/proc/[pid]/limits");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CGROUP, "/proc/[pid]/cgroup");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_PROC_PID_STATUS, "/proc/[pid]/status");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_MOUNTINFO, "/proc/[pid]/mountinfo");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CRASH_FUNCTION, "main");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_REMOTE, "0");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_RATING, "4");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_EXPLOITABLE, "6");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_TAINTED, "Not tainted");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_TAINTED_SHORT, "Not tainted");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_TAINTED_LONG, "Not tainted");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_NOT_REPORTABLE, "Despite 'not tainted' this problem cannot be reported.");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_REPORTED_TO, "Bugzilla: URL=https://bugzilla.redhat.com/1000000");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_EVENT_LOG, "--- report_Bugzilla has finished successfully ---");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_KICKSTART_CFG, "kickstart.cfg");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_ANACONDA_TB, "anaconda.tb");
|
|
|
562801 |
+
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_NAMESPACES, "FILENAME_NAMESPACES");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_OS_INFO_IN_ROOTDIR, "FILENAME_OS_INFO_IN_ROOTDIR");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_OS_RELEASE_IN_ROOTDIR, "FILENAME_OS_RELEASE_IN_ROOTDIR");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_KERNEL_LOG, "FILENAME_KERNEL_LOG");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_DESCRIPTION, "FILENAME_DESCRIPTION");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CORE_BACKTRACE, "FILENAME_CORE_BACKTRACE");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_REMOTE_RESULT, "FILENAME_REMOTE_RESULT");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_ABRT_VERSION, "FILENAME_ABRT_VERSION");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CONTAINER, "FILENAME_CONTAINER");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CONTAINER_ID, "FILENAME_CONTAINER_ID");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CONTAINER_UUID, "FILENAME_CONTAINER_UUID");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CONTAINER_IMAGE, "FILENAME_CONTAINER_IMAGE");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_CONTAINER_CMDLINE, "FILENAME_CONTAINER_CMDLINE");
|
|
|
562801 |
+ dd_save_text(dd, FILENAME_DOCKER_INSPECT, "FILENAME_DOCKER_INSPECT");
|
|
|
562801 |
+
|
|
|
562801 |
+ dd_save_text(dd, "attestsuite-random-file", "random content");
|
|
|
562801 |
+ dd_save_text(dd, "attestsuite-oneliner-newline", "newline\n");
|
|
|
562801 |
+ dd_save_text(dd, "attestsuite-newline-followed", "newline\nfollowed");
|
|
|
562801 |
+ dd_save_text(dd, "attestsuite-multi-line", "newline\nextra\n");
|
|
|
562801 |
+ dd_save_text(dd, "attestsuite-tab", "tab\ttab");
|
|
|
562801 |
+ dd_save_text(dd, "attestsuite-cr", "cr\rcr");
|
|
|
562801 |
+
|
|
|
562801 |
+ char buffer[1024*3];
|
|
|
562801 |
+ memset(buffer, 'x', sizeof(buffer));
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ int fd4k = openat(dd->dd_fd, "attestsuite-over4k", O_WRONLY | O_CREAT | O_TRUNC, 0550);
|
|
|
562801 |
+ assert(fd4k >= 0);
|
|
|
562801 |
+ full_write(fd4k, buffer, sizeof(buffer));
|
|
|
562801 |
+ full_write(fd4k, buffer, sizeof(buffer));
|
|
|
562801 |
+ close(fd4k);
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ int bigfd = openat(dd->dd_fd, "attestsuite-bigtext", O_WRONLY | O_CREAT | O_TRUNC, 0550);
|
|
|
562801 |
+ assert(bigfd >= 0);
|
|
|
562801 |
+ for (int i = 3000; i > 0; --i)
|
|
|
562801 |
+ full_write(bigfd, buffer, sizeof(buffer));
|
|
|
562801 |
+ close(bigfd);
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ dd_copy_file(dd, FILENAME_BINARY, "/usr/bin/sh");
|
|
|
562801 |
+ dd_copy_file(dd, FILENAME_COREDUMP, "/usr/bin/sh");
|
|
|
562801 |
+ dd_copy_file(dd, FILENAME_VMCORE, "/usr/bin/sh");
|
|
|
562801 |
+
|
|
|
562801 |
+ static const char *const list_elements[] = { FILENAME_UID, FILENAME_PACKAGE,
|
|
|
562801 |
+ FILENAME_CMDLINE, FILENAME_TIME, FILENAME_COUNT, FILENAME_REASON };
|
|
|
562801 |
+
|
|
|
562801 |
+ static const char *const editable_files[] = { FILENAME_COMMENT, FILENAME_BACKTRACE,
|
|
|
562801 |
+ FILENAME_REASON, FILENAME_OPEN_FDS, FILENAME_CMDLINE, FILENAME_MAPS,
|
|
|
562801 |
+ FILENAME_SMAPS, FILENAME_ENVIRON, FILENAME_HOSTNAME, FILENAME_REMOTE,
|
|
|
562801 |
+ FILENAME_KICKSTART_CFG, FILENAME_ANACONDA_TB, };
|
|
|
562801 |
+
|
|
|
562801 |
+ static const char *const binary_files[] = { FILENAME_BINARY, FILENAME_COREDUMP,
|
|
|
562801 |
+ FILENAME_VMCORE, };
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_t *pd = problem_data_new();
|
|
|
562801 |
+ problem_data_load_from_dump_dir(pd, dd, /*excluding*/NULL);
|
|
|
562801 |
+
|
|
|
562801 |
+ GHashTableIter pd_iter;
|
|
|
562801 |
+ char *element_name;
|
|
|
562801 |
+ struct problem_item *item;
|
|
|
562801 |
+ g_hash_table_iter_init(&pd_iter, pd);
|
|
|
562801 |
+ while (g_hash_table_iter_next(&pd_iter, (void**)&element_name, (void**)&item))
|
|
|
562801 |
+ {
|
|
|
562801 |
+ printf("Testing element : %s\n", element_name);
|
|
|
562801 |
+
|
|
|
562801 |
+ size_t i;
|
|
|
562801 |
+ for (i = 0; i < ARRAY_SIZE(list_elements); ++i)
|
|
|
562801 |
+ {
|
|
|
562801 |
+ if (strcmp(element_name, list_elements[i]) == 0)
|
|
|
562801 |
+ {
|
|
|
562801 |
+ assert((item->flags & CD_FLAG_LIST));
|
|
|
562801 |
+ break;
|
|
|
562801 |
+ }
|
|
|
562801 |
+ }
|
|
|
562801 |
+ if (i == ARRAY_SIZE(list_elements))
|
|
|
562801 |
+ assert(!(item->flags & CD_FLAG_LIST));
|
|
|
562801 |
+
|
|
|
562801 |
+ for (i = 0; i < ARRAY_SIZE(editable_files); ++i)
|
|
|
562801 |
+ {
|
|
|
562801 |
+ if (strcmp(element_name, editable_files[i]) == 0)
|
|
|
562801 |
+ {
|
|
|
562801 |
+ assert((item->flags & CD_FLAG_ISEDITABLE) && !(item->flags & CD_FLAG_ISNOTEDITABLE));
|
|
|
562801 |
+ break;
|
|
|
562801 |
+ }
|
|
|
562801 |
+ }
|
|
|
562801 |
+ if (i == ARRAY_SIZE(editable_files))
|
|
|
562801 |
+ assert(!(item->flags & CD_FLAG_ISEDITABLE) && (item->flags & CD_FLAG_ISNOTEDITABLE));
|
|
|
562801 |
+
|
|
|
562801 |
+ for (i = 0; i < ARRAY_SIZE(binary_files); ++i)
|
|
|
562801 |
+ {
|
|
|
562801 |
+ if (strcmp(element_name, binary_files[i]) == 0)
|
|
|
562801 |
+ {
|
|
|
562801 |
+ assert((item->flags & CD_FLAG_BIN) && !(item->flags & CD_FLAG_TXT) && !(item->flags & CD_FLAG_BIGTXT));
|
|
|
562801 |
+ break;
|
|
|
562801 |
+ }
|
|
|
562801 |
+ }
|
|
|
562801 |
+ if (i == ARRAY_SIZE(binary_files))
|
|
|
562801 |
+ {
|
|
|
562801 |
+ if(strstr(element_name, "bigtext") == 0)
|
|
|
562801 |
+ assert((item->flags & CD_FLAG_TXT) && !(item->flags & CD_FLAG_BIN) && !(item->flags & CD_FLAG_BIGTXT));
|
|
|
562801 |
+ else
|
|
|
562801 |
+ assert((item->flags & CD_FLAG_BIGTXT) && (item->flags & CD_FLAG_BIN) && !(item->flags & CD_FLAG_TXT));
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ if (strcmp(element_name, FILENAME_TIME) == 0)
|
|
|
562801 |
+ assert(item->flags & CD_FLAG_UNIXTIME);
|
|
|
562801 |
+ else
|
|
|
562801 |
+ assert(!(item->flags & CD_FLAG_UNIXTIME));
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ char *cnt = problem_data_get_content_or_NULL(pd, "attestsuite-oneliner-newline");
|
|
|
562801 |
+ assert(cnt != NULL && "attestsuite-oneliner-newline");
|
|
|
562801 |
+ assert(strcmp(cnt, "newline") == 0);
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ char *cnt = problem_data_get_content_or_NULL(pd, "attestsuite-newline-followed");
|
|
|
562801 |
+ assert(cnt != NULL && "attestsuite-newline-followed");
|
|
|
562801 |
+ assert(strcmp(cnt, "newline\nfollowed") == 0);
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ char *cnt = problem_data_get_content_or_NULL(pd, "attestsuite-multi-line");
|
|
|
562801 |
+ assert(cnt != NULL && "attestsuite-multi-line");
|
|
|
562801 |
+ assert(strcmp(cnt, "newline\nextra\n") == 0);
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ char *cnt = problem_data_get_content_or_NULL(pd, "attestsuite-over4k");
|
|
|
562801 |
+ assert(cnt != NULL && "attestsuite-over4k");
|
|
|
562801 |
+ assert(strlen(cnt) == (2 * sizeof(buffer)));
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ char *cnt = problem_data_get_content_or_NULL(pd, "attestsuite-tab");
|
|
|
562801 |
+ assert(cnt != NULL && "attestsuite-tab");
|
|
|
562801 |
+ assert(strcmp(cnt, "tab\ttab") == 0);
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ {
|
|
|
562801 |
+ char *cnt = problem_data_get_content_or_NULL(pd, "attestsuite-cr");
|
|
|
562801 |
+ assert(cnt != NULL && "attestsuite-cr");
|
|
|
562801 |
+ assert(strcmp(cnt, "cr[0D]cr") == 0);
|
|
|
562801 |
+ }
|
|
|
562801 |
+
|
|
|
562801 |
+ return 0;
|
|
|
562801 |
+}
|
|
|
562801 |
+]])
|
|
|
562801 |
+
|
|
|
562801 |
+## ------------------------- ##
|
|
|
562801 |
+## problem_data_reproducible ##
|
|
|
562801 |
+## ------------------------- ##
|
|
|
562801 |
+
|
|
|
562801 |
+AT_TESTFUN([problem_data_reproducible],
|
|
|
562801 |
+[[
|
|
|
562801 |
+#include "testsuite.h"
|
|
|
562801 |
+
|
|
|
562801 |
+#define TEST_FLAGS (CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE | CD_FLAG_UNIXTIME)
|
|
|
562801 |
+
|
|
|
562801 |
+TS_MAIN
|
|
|
562801 |
+{
|
|
|
562801 |
+ TS_ASSERT_STRING_NULL_OR_EMPTY(get_problem_data_reproducible_name(-1), "Invalid value");
|
|
|
562801 |
+ TS_ASSERT_PTR_IS_NOT_NULL(get_problem_data_reproducible_name(PROBLEM_REPRODUCIBLE_UNKNOWN));
|
|
|
562801 |
+ TS_ASSERT_PTR_IS_NOT_NULL(get_problem_data_reproducible_name(PROBLEM_REPRODUCIBLE_YES));
|
|
|
562801 |
+ TS_ASSERT_PTR_IS_NOT_NULL(get_problem_data_reproducible_name(PROBLEM_REPRODUCIBLE_RECURRENT));
|
|
|
562801 |
+ TS_ASSERT_STRING_NULL_OR_EMPTY(get_problem_data_reproducible_name(_PROBLEM_REPRODUCIBLE_MAX_), "Upper boundary");
|
|
|
562801 |
+ TS_ASSERT_STRING_NULL_OR_EMPTY(get_problem_data_reproducible_name(_PROBLEM_REPRODUCIBLE_MAX_ + 1), "Upper boundary + 1");
|
|
|
562801 |
+ TS_ASSERT_SIGNED_EQ(_PROBLEM_REPRODUCIBLE_MAX_, 3);
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_t *pd = problem_data_new();
|
|
|
562801 |
+
|
|
|
562801 |
+ TS_ASSERT_SIGNED_EQ(get_problem_data_reproducible(pd), -1);
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_add(pd, FILENAME_REPRODUCIBLE,
|
|
|
562801 |
+ get_problem_data_reproducible_name(PROBLEM_REPRODUCIBLE_UNKNOWN), TEST_FLAGS);
|
|
|
562801 |
+ TS_ASSERT_SIGNED_EQ(get_problem_data_reproducible(pd), PROBLEM_REPRODUCIBLE_UNKNOWN);
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_add(pd, FILENAME_REPRODUCIBLE,
|
|
|
562801 |
+ get_problem_data_reproducible_name(PROBLEM_REPRODUCIBLE_YES), TEST_FLAGS);
|
|
|
562801 |
+ TS_ASSERT_SIGNED_EQ(get_problem_data_reproducible(pd), PROBLEM_REPRODUCIBLE_YES);
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_add(pd, FILENAME_REPRODUCIBLE,
|
|
|
562801 |
+ get_problem_data_reproducible_name(PROBLEM_REPRODUCIBLE_RECURRENT), TEST_FLAGS);
|
|
|
562801 |
+ TS_ASSERT_SIGNED_EQ(get_problem_data_reproducible(pd), PROBLEM_REPRODUCIBLE_RECURRENT);
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_add(pd, FILENAME_REPRODUCIBLE,
|
|
|
562801 |
+ get_problem_data_reproducible_name(_PROBLEM_REPRODUCIBLE_MAX_), TEST_FLAGS);
|
|
|
562801 |
+ TS_ASSERT_SIGNED_EQ(get_problem_data_reproducible(pd), -1);
|
|
|
562801 |
+
|
|
|
562801 |
+ problem_data_free(pd);
|
|
|
562801 |
+}
|
|
|
562801 |
+TS_RETURN_MAIN
|
|
|
562801 |
+]])
|
|
|
562801 |
--
|
|
|
562801 |
1.8.3.1
|
|
|
562801 |
|