janwas
a859562ea7
- properly differentiate between buffer/offset alignment and length alignment (relevant since block size has been increased to 256k) - use VfsPath for most game paths instead of CStr - clean up timer interface and implementation - self-tests no longer crash - file_cache.cpp: fix for the case where allocation fails (prevent deleter from seeing a null pointer) - allocators: move all shared_ptr-related stuff to its own component; add DummySharedPtr - codec: disable checksums (important for performance at work) - File: made into an interface class to avoid export problems. not entirely sure about this.. - vfs_path.h, path.h, os_path.h: proper fix for using fs::change_extension and similar utility functions with derivatives of basic_path - lib_api: automatically link against import lib if building lib/ as a DLL - path_util: remove unused functions (this component is deprecated) - compiler.h: add INLINE - Xeromyces.cpp: pass PIVFS so that GetXMBPath works in self-test (should do this mostly everywhere rather than have one singleton g_VFS) This was SVN commit r5537.
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
/**
|
|
* =========================================================================
|
|
* File : self_test.cpp
|
|
* Project : 0 A.D.
|
|
* Description : helpers for built-in self tests
|
|
* =========================================================================
|
|
*/
|
|
|
|
// license: GPL; see lib/license.txt
|
|
|
|
#include "precompiled.h"
|
|
|
|
#if 0
|
|
|
|
#include "self_test.h"
|
|
#include "timer.h"
|
|
|
|
// checked by debug_assert_failed; disables asserts if true (see above).
|
|
// set/cleared by self_test_run.
|
|
bool self_test_active = false;
|
|
|
|
// trampoline that sets self_test_active and returns a dummy value;
|
|
// used by SELF_TEST_RUN.
|
|
int self_test_run(void (*func)())
|
|
{
|
|
self_test_active = true;
|
|
func();
|
|
self_test_active = false;
|
|
return 0; // assigned to dummy at file scope
|
|
}
|
|
|
|
|
|
static const SelfTestRecord* registered_tests;
|
|
|
|
int self_test_register(SelfTestRecord* r)
|
|
{
|
|
// SELF_TEST_REGISTER has already initialized r->func.
|
|
r->next = registered_tests;
|
|
registered_tests = r;
|
|
return 0; // assigned to dummy at file scope
|
|
}
|
|
|
|
|
|
void self_test_run_all()
|
|
{
|
|
debug_printf("SELF TESTS:\n");
|
|
const double t0 = timer_Time();
|
|
|
|
// someone somewhere may want to run self-tests twice (e.g. to help
|
|
// track down memory corruption), so don't destroy the list while
|
|
// iterating over it.
|
|
const SelfTestRecord* r = registered_tests;
|
|
while(r)
|
|
{
|
|
self_test_run(r->func);
|
|
r = r->next;
|
|
}
|
|
|
|
const double dt = timer_Time() - t0;
|
|
debug_printf("-- done (elapsed time %.0f ms)\n", dt*1e3);
|
|
}
|
|
|
|
#endif
|