34#ifdef DEBUG_MEMORY_LIMITER
48#define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
60 test_memory_limiter() {}
71 mem_record(
int parent_in = 0,
int allocated_in = 0)
72 : parent(parent_in), allocated(allocated_in) {}
75struct memorial :
array<mem_record> {};
79int test_memory_limiter::execute()
99 if (!to_test.okay_allocation(parent, alloc))
101 wtc += mem_record(parent, alloc);
103 total_allocated += alloc;
104 }
else if (to_do < 88) {
106 if (!wtc.length())
continue;
107 int indy =
randomizer().inclusive(0, wtc.length() - 1);
108 mem_record to_gone = wtc[indy];
110 ASSERT_TRUE(to_test.record_deletion(to_gone.parent, to_gone.allocated),
111 "first case failed to record deletion!");
113 total_deleted += to_gone.allocated;
120 for (
int i = 0; i < wtc.length(); i++) {
121 mem_record to_gone = wtc[i];
122 ASSERT_TRUE(to_test.record_deletion(to_gone.parent, to_gone.allocated),
123 "second case failed to record deletion!");
125 total_deleted += to_gone.allocated;
130 ASSERT_FALSE(to_test.overall_usage(),
"final checks: there is still memory in use!");
133 "final checks: the free space is not correct!");
135 int_set remaining = to_test.individuals_listed();
140 LOG(
"stats for this run:");
144 allocations, total_allocated));
146 deletions, total_deleted));
148 return final_report();
The application_shell is a base object for console programs.
virtual int execute()=0
< retrieves the command line from the /proc hierarchy on linux.
Represents a sequential, ordered, contiguous collection of objects.
Provides a dynamically resizable ASCII character string.
A simple object that wraps a templated set of ints.
Tracks memory currently in use by memory manager objects.
int elements() const
Returns the number of elements in this set.
Represents a point in time relative to the operating system startup time.
time_representation value() const
returns the time_stamp in terms of the lower level type.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
const int MEGABYTE
Number of bytes in a megabyte.
const int SECOND_ms
Number of milliseconds in a second.
unsigned int un_int
Abbreviated name for unsigned integers.
const int KILOBYTE
Number of bytes in a kilobyte.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
const int MAXIMUM_MEM_PER_OWNER
const int MAXIMUM_MEM_OVERALL
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)
#define ASSERT_FALSE(a, test_name)