Skip to content

Commit

Permalink
tests: add 32bit state file to test
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Sep 29, 2020
1 parent ac0e36a commit b04bb4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions core/src/tests/recent_job_results_list.cc
Expand Up @@ -32,13 +32,18 @@
#include <iostream>
#include <fstream>

static auto Is32BitWordsize = []() { return sizeof(void*) == 4; };

TEST(recent_job_results_list, read_job_results_from_file)
{
OSDependentInit();
RecentJobResultsList::Cleanup();

char orig_path[]{TEST_ORIGINAL_FILE_DIR};
ReadStateFile(orig_path, "bareos-dir", 42001);

const char *fname = Is32BitWordsize() ? "bareos-dir-32bit" : "bareos-dir";

ReadStateFile(orig_path, fname, 42001);

static std::vector<RecentJobResultsList::JobResult> recent_jobs =
RecentJobResultsList::Get();
Expand All @@ -57,15 +62,17 @@ TEST(recent_job_results_list, write_job_results_to_file)
OSDependentInit();
RecentJobResultsList::Cleanup();

const char *fname = Is32BitWordsize() ? "bareos-dir-32bit" : "bareos-dir";

char orig_path[]{TEST_ORIGINAL_FILE_DIR};
ReadStateFile(orig_path, "bareos-dir", 42001);
ReadStateFile(orig_path, fname, 42001);

char path[]{TEST_TEMP_DIR};
WriteStateFile(path, "bareos-dir", 42001);
WriteStateFile(path, fname, 42001);

RecentJobResultsList::Cleanup();

ReadStateFile(path, "bareos-dir", 42001);
ReadStateFile(path, fname, 42001);

static std::vector<RecentJobResultsList::JobResult> recent_jobs =
RecentJobResultsList::Get();
Expand Down Expand Up @@ -115,8 +122,13 @@ TEST(recent_job_results_list, read_job_results_from_file_truncated_jobs)
RecentJobResultsList::Cleanup();

char orig_path[]{TEST_ORIGINAL_FILE_DIR};
ASSERT_TRUE(create_file(orig_path, "bareos-dir-truncated-jobs.42001.state"));
ReadStateFile(orig_path, "bareos-dir-truncated-jobs", 42001);

const char *fname = Is32BitWordsize()
? "bareos-dir-truncated-jobs-32bit"
: "bareos-dir-truncated-jobs";

ASSERT_TRUE(create_file(orig_path, std::string(fname) + ".42001.state"));
ReadStateFile(orig_path, fname, 42001);

static std::vector<RecentJobResultsList::JobResult> recent_jobs =
RecentJobResultsList::Get();
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit b04bb4c

Please sign in to comment.