xref: /haiku/src/tests/kits/storage/NodeTest.h (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
1 // NodeTest.h
2 
3 #ifndef __sk_node_test_h__
4 #define __sk_node_test_h__
5 
6 #include "StatableTest.h"
7 
8 class BNode;
9 
10 typedef TestEntries<BNode> TestNodes;
11 
12 class NodeTest : public StatableTest {
13 public:
14 	static CppUnit::Test* Suite();
15 
16 	template<typename DerivedClass>
17 	static inline void AddBaseClassTests(const char *prefix,
18 										 CppUnit::TestSuite *suite);
19 
20 	virtual void CreateROStatables(TestStatables& testEntries);
21 	virtual void CreateRWStatables(TestStatables& testEntries);
22 	virtual void CreateUninitializedStatables(TestStatables& testEntries);
23 
24 	virtual void CreateRONodes(TestNodes& testEntries);
25 	virtual void CreateRWNodes(TestNodes& testEntries);
26 	virtual void CreateUninitializedNodes(TestNodes& testEntries);
27 
28 	// This function is called before *each* test added in Suite()
29 	void setUp();
30 
31 	// This function is called after *each* test added in Suite()
32 	void tearDown();
33 
34 	// Tests
35 	void InitTest1();
36 	void InitTest2();
37 	void AttrDirTest();
38 	void AttrTest();
39 	void AttrRenameTest();
40 	void AttrInfoTest();
41 	void AttrBStringTest();
42 	void DupTest();
43 	void SyncTest();
44 	void EqualityTest();
45 	void AssignmentTest();
46 	void LockTest(); // Locking isn't implemented for the Posix versions
47 
48 	// Helper functions
49 	void AttrDirTest(BNode &node);
50 	void AttrTest(BNode &node);
51 	void AttrRenameTest(BNode &node);
52 	void AttrInfoTest(BNode &node);
53 	void AttrBStringTest(BNode &node);
54 	void DupTest(BNode &node);
55 	void LockTest(BNode &node, const char *entryName);
56 	void EqualityTest(BNode &n1, BNode &n2, BNode &y1a, BNode &y1b, BNode &y2);
57 
58 	// entry names used by this class or derived classes
59 	static	const char *		existingFilename;
60 	static	const char *		existingSuperFilename;
61 	static	const char *		existingRelFilename;
62 	static	const char *		existingDirname;
63 	static	const char *		existingSuperDirname;
64 	static	const char *		existingRelDirname;
65 	static	const char *		existingSubDirname;
66 	static	const char *		existingRelSubDirname;
67 	static	const char *		nonExistingFilename;
68 	static	const char *		nonExistingDirname;
69 	static	const char *		nonExistingSuperDirname;
70 	static	const char *		nonExistingRelDirname;
71 	static	const char *		testFilename1;
72 	static	const char *		testDirname1;
73 	static	const char *		tooLongEntryname;
74 	static	const char *		tooLongSuperEntryname;
75 	static	const char *		tooLongRelEntryname;
76 	static	const char *		fileDirname;
77 	static	const char *		fileSuperDirname;
78 	static	const char *		fileRelDirname;
79 	static	const char *		dirLinkname;
80 	static	const char *		dirSuperLinkname;
81 	static	const char *		dirRelLinkname;
82 	static	const char *		fileLinkname;
83 	static	const char *		fileSuperLinkname;
84 	static	const char *		fileRelLinkname;
85 	static	const char *		relDirLinkname;
86 	static	const char *		relFileLinkname;
87 	static	const char *		badLinkname;
88 	static	const char *		cyclicLinkname1;
89 	static	const char *		cyclicLinkname2;
90 
91 	static	const char *		allFilenames[];
92 	static	const int32 		allFilenameCount;
93 };
94 
95 // AddBaseClassTests
96 template<typename DerivedClass>
97 inline void
98 NodeTest::AddBaseClassTests(const char *prefix, CppUnit::TestSuite *suite)
99 {
100 	StatableTest::AddBaseClassTests<DerivedClass>(prefix, suite);
101 
102 	typedef CppUnit::TestCaller<DerivedClass> TC;
103 	string p(prefix);
104 
105 	suite->addTest( new TC(p + "BNode::AttrDir Test", &NodeTest::AttrDirTest) );
106 	suite->addTest( new TC(p + "BNode::Attr Test", &NodeTest::AttrTest) );
107 	suite->addTest( new TC(p + "BNode::AttrRename Test"
108 #if TEST_R5
109 								" (NOTE: test not actually performed with R5 libraries)"
110 #endif
111 								, &NodeTest::AttrRenameTest) );
112 	suite->addTest( new TC(p + "BNode::AttrInfo Test", &NodeTest::AttrInfoTest) );
113 	// TODO: AttrBString deadlocks entire OS (UnitTester at 100% CPU,
114 	// windows don't respond to actions, won't open, OS won't even shut down)
115 	//suite->addTest( new TC(p + "BNode::AttrBString Test", &NodeTest::AttrBStringTest) );
116 	suite->addTest( new TC(p + "BNode::Sync Test", &NodeTest::SyncTest) );
117 	suite->addTest( new TC(p + "BNode::Dup Test", &NodeTest::DupTest) );
118 	suite->addTest( new TC(p + "BNode::Lock Test"
119 #if TEST_OBOS /* !!!POSIX ONLY!!! */
120 								" (NOTE: test not actually performed with Haiku Posix libraries)"
121 #endif
122 								, &NodeTest::LockTest) );
123 }
124 
125 
126 #endif	// __sk_node_test_h__
127 
128 
129 
130 
131