summaryrefslogtreecommitdiff
path: root/test/testmain.cc
blob: db8e22cf48981323c9d304c8958aa1e71f74b1f1 (plain)
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
// -*- c++ -*-
// Distributed under the BSD 2-Clause License.
// See accompanying file LICENSE for details.
#define uUNIT_MAIN
#include "uunit.h"

#include <fstream>
#include <string>
#include <filesystem>

namespace paths
{
std::string argv_0;
std::filesystem::path top_srcdir;
std::filesystem::path top_builddir;
std::filesystem::path testdir;
}

int main(int argc, char* argv[])
{
	(void)argc;

	paths::argv_0 = argv[0];

	auto cur = std::filesystem::current_path();
	paths::testdir = std::filesystem::path(paths::argv_0).parent_path();
	// assuming <builddir>/test
	paths::top_builddir = paths::testdir.parent_path();
	paths::top_srcdir = std::filesystem::relative(cur, paths::testdir);

	std::filesystem::current_path(paths::testdir);

	std::ofstream xmlfile;
	xmlfile.open("result_" OUTPUT ".xml");
	return uUnit::runTests(xmlfile);
}