2 * Name : test_system_preconditions
3 * Author : Chris Koeritz
5 * Copyright (c) 1993-$now By Author. This program is free software; you can
6 * redistribute it and/or modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation; either version 2 of
8 * the License or (at your option) any later version. This is online at:
9 * http://www.fsf.org/copyleft/gpl.html
10 * Please send any updates to: fred@gruntose.com
15 #include <application/hoople_main.h>
16 #include <application/windoze_helper.h>
17 #include <basis/astring.h>
18 #include <basis/enhance_cpp.h>
19 #include <basis/functions.h>
20 #include <basis/guards.h>
21 #include <configuration/application_configuration.h>
22 #include <loggers/critical_events.h>
23 #include <loggers/console_logger.h>
24 #include <structures/version_record.h>
25 #include <structures/static_memory_gremlin.h>
26 #include <unit_test/unit_base.h>
30 using namespace application;
31 using namespace basis;
32 using namespace configuration;
33 using namespace loggers;
34 using namespace system_checkup;
35 using namespace structures;
36 using namespace unit_test;
38 class test_system_preconditions : virtual public unit_base, virtual public application_shell
41 test_system_preconditions() : application_shell() {}
42 DEFINE_CLASS_NAME("test_system_preconditions");
43 virtual int execute();
48 #undef UNIT_BASE_THIS_OBJECT
49 #define UNIT_BASE_THIS_OBJECT c_parent
54 burpee(unit_base &parent) : c_parent(parent), my_string(new astring) { *my_string = "balrog"; }
55 DEFINE_CLASS_NAME("burpee");
57 FUNCDEF("destructor");
59 ASSERT_FALSE(my_string, "whack test should not fail to clear string");
69 #undef UNIT_BASE_THIS_OBJECT
73 #define UNIT_BASE_THIS_OBJECT c_parent
75 class florba : public burpee
78 florba(unit_base &parent) : burpee(parent), second_string(new astring)
79 { *second_string = "loquacious"; }
80 DEFINE_CLASS_NAME("florba");
82 FUNCDEF("destructor");
84 ASSERT_FALSE(second_string, "whack test should clear string in derived class");
88 astring *second_string;
91 #undef UNIT_BASE_THIS_OBJECT
95 // back to default now.
96 #define UNIT_BASE_THIS_OBJECT (*this)
98 struct testing_file_struct : public FILE {};
100 // NOTE: an important part of this test program is running it under something
101 // like boundschecker to ensure that there are no memory leaks caused by
102 // invoking WHACK. apparently diab 3 is unable to implement WHACK correctly.
104 int test_system_preconditions::execute()
107 // let's see what this system is called.
108 log(astring("The name of this software system is: ")
109 + application_configuration::software_product_name());
110 ASSERT_TRUE(strlen(application_configuration::software_product_name()),
111 "product should not be blank");
113 // and what this program is called.
114 log(astring("The application is called: ") + application_configuration::application_name());
115 ASSERT_TRUE(application_configuration::application_name().length(),
116 "application name should not be blank");
118 // testing compiler's ansi c++ compliance.
119 for (int q = 0; q < 198; q++) {
121 int malfoy = treno * 3;
122 // log(a_sprintf("%d", malfoy));
124 // this should not be an error. the scope of q should be within the loop and
125 // not outside of it.
127 ASSERT_FALSE(q > 190, "no weirdness should happen with compiler scoping");
129 // test that the WHACK function operates properly.
130 burpee *chunko = new burpee(*this);
131 florba *lorkas = new florba(*this);
132 burpee *alias = lorkas;
136 ASSERT_FALSE(chunko, "chunko whack test should succeed");
137 ASSERT_FALSE(alias, "aliased lorkas whack test should succeed");
138 ASSERT_TRUE(lorkas, "original lorkas should not have been cleared");
139 lorkas = NULL_POINTER;
141 ASSERT_EQUAL((int)sizeof(testing_file_struct), (int)sizeof(FILE),
142 "struct size test, sizeof testing_file_struct and sizeof FILE should not differ");
144 // now do the crucial tests on the OS, platform, compiler, etc.
145 ASSERT_TRUE(check_system_characteristics(*this),
146 "required system characteristics should be found");
149 known_operating_systems os = determine_OS();
150 astring os_report = "This OS is: ";
151 os_report += opsystem_name(os);
153 printf(os_report.s());
156 version os_ver = application_configuration::get_OS_version();
157 printf("OS version: %s\n", os_ver.text_form().s());
159 return final_report();
162 HOOPLE_MAIN(test_system_preconditions, )