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