summaryrefslogtreecommitdiff
path: root/unittests/core.cpp
blob: 9b38dfe51010f2abba5ab46c49ca1f182252d8e4 (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, "/metadata", R_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/metadata", W_OK));
	BOOST_CHECK_EQUAL(0, v->access(env, "/metadata", X_OK));

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

	BOOST_CHECK_EQUAL(0, v->access(env, "/app-antivirus/skyldav/files/skyldav.initd", R_OK));
	BOOST_CHECK_EQUAL(EACCES, v->access(env, "/app-antivirus/skyldav/files/skyldav.initd", W_OK));
	BOOST_CHECK_EQUAL(0, v->access(env, "/app-antivirus/skyldav/files/skyldav.initd", 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();