File: process_tests.cpp

package info (click to toggle)
pion 5.0.7%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,048 kB
  • ctags: 3,122
  • sloc: cpp: 14,237; perl: 269; pascal: 152; makefile: 145; sh: 70
file content (80 lines) | stat: -rw-r--r-- 2,312 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ---------------------------------------------------------------------
// pion:  a Boost C++ framework for building lightweight HTTP interfaces
// ---------------------------------------------------------------------
// Copyright (C) 2007-2014 Splunk Inc.  (https://github.com/splunk/pion)
//
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//

#include <pion/config.hpp>
#include <pion/test/unit_test.hpp>
#include <boost/test/unit_test.hpp>
#include <pion/process.hpp>

using namespace pion;

class ProcessTest_F : public process
{
public:
};

BOOST_FIXTURE_TEST_SUITE(ProcessTest_S, ProcessTest_F)

#ifdef _MSC_VER
BOOST_AUTO_TEST_CASE(checkSetDumpfileDirectory)
{
    // check that invalid input results in an exception
    BOOST_CHECK_THROW(set_dumpfile_directory("::invalid_dir_name::"), dumpfile_init_exception);

    // grab temp path
    char temp_path[MAX_PATH];
    ::GetTempPath(MAX_PATH, temp_path);

    // check that the call succeeds with valid parameters
    BOOST_CHECK_NO_THROW(set_dumpfile_directory(temp_path));

    // check some expected post-conditions
    config_type& cfg = get_config();

    // dump file directory must be the one we just set
    BOOST_CHECK(cfg.dumpfile_dir == temp_path);

    // MiniDumpWriteDump proc address must be not null after successfull call
    BOOST_CHECK(cfg.p_dump_proc != NULL);
}

BOOST_AUTO_TEST_CASE(checkResetDumpfileDirectory)
{
    // check that the call succeeds
    BOOST_CHECK_NO_THROW(set_dumpfile_directory(""));

    // check some expected post-conditions
    config_type& cfg = get_config();

    // dump file directory must be the one we just set
    BOOST_CHECK(cfg.dumpfile_dir == "");

    // MiniDumpWriteDump proc address must be null
    BOOST_CHECK(cfg.p_dump_proc == NULL);
}

BOOST_AUTO_TEST_CASE(checkGenerateDumpFileName)
{
    // grab temp path
    char temp_path[MAX_PATH];
    ::GetTempPath(MAX_PATH, temp_path);

    // set dumpfile directory
    BOOST_CHECK_NO_THROW(set_dumpfile_directory(temp_path));

    std::string dumpfile_name = generate_dumpfile_name();

    BOOST_CHECK(!dumpfile_name.empty());

    // temp file must be in a specified directory
    BOOST_CHECK(dumpfile_name.find(temp_path) != std::string::npos);
}
#endif

BOOST_AUTO_TEST_SUITE_END()