summaryrefslogtreecommitdiff
path: root/unittests/core.cpp
blob: aad6b6561c2ab25e436587fc86c0a01290cdd2ff (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
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
#define BOOST_TEST_MODULE GitFS_Core
#include <boost/test/unit_test.hpp>

#include "mockDefs.h"
#include "sys/stat.h"

using namespace GitFS;
using namespace GitFS::Test;

BOOST_TEST_GLOBAL_FIXTURE(Service);

BOOST_FIXTURE_TEST_SUITE(client, Client)

	// TODO

BOOST_AUTO_TEST_SUITE_END();

BOOST_FIXTURE_TEST_SUITE(volume, VolumeClient)

BOOST_AUTO_TEST_CASE( access )
{
	// Noting is writable
	// Directories are all readable and executable

	BOOST_CHECK_EQUAL(EINVAL, v->access(env, "", R_OK));

	BOOST_CHECK_EQUAL(0, v->access(env, "/", R_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/", W_OK));
	BOOST_CHECK_EQUAL(0, v->access(env, "/", X_OK));

	BOOST_CHECK_EQUAL(0, v->access(env, "/src", R_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/src", W_OK));
	BOOST_CHECK_EQUAL(0, v->access(env, "/src", X_OK));

	BOOST_CHECK_EQUAL(0, v->access(env, "/src/Jamfile.jam", R_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/src/Jamfile.jam", W_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/src/Jamfile.jam", X_OK));

	BOOST_CHECK_EQUAL(0, v->access(env, "/unittests/fixtures/executable", R_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/unittests/fixtures/executable", W_OK));
	BOOST_CHECK_EQUAL(0, v->access(env, "/unittests/fixtures/executable", X_OK));

	BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/missing", R_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/missing", W_OK));
	BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/missing", X_OK));

	BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/.", R_OK));
	BOOST_CHECK_EQUAL(ENOENT, v->access(env, "/../", R_OK));
	BOOST_CHECK_EQUAL(ENOENT, v->access(env, ".", R_OK));
	BOOST_CHECK_EQUAL(ENOENT, v->access(env, "..", R_OK));
	BOOST_CHECK_EQUAL(ENOENT, v->access(env, "../", R_OK));
}

BOOST_AUTO_TEST_CASE( statRoot )
{
	//auto a = v->getattr(env, "/");
	//BOOST_CHECK_EQUAL(0170555, a.mode);
	//BOOST_CHECK_EQUAL(1563566842, a.mtime);
	//BOOST_CHECK_EQUAL(1563566842, a.ctime);
	//BOOST_CHECK_EQUAL(1563566842, a.atime);
}

BOOST_AUTO_TEST_CASE(stat_root)
{
	auto attr = v->getattr(env, "");
}

BOOST_AUTO_TEST_SUITE_END();