Beispiel #1
0
int main(){
	t1();
	t2();
	t3();
	t4();
	t5();
	t6();
	t7();
	t8();
	t9();
	t10();
	t11();
	t12();
	t13();
	t14();
	t15();
	t16();
	t17();
	return 0;
}
Beispiel #2
0
void testFill ()
{
  BTree<int> empty;
  BTree<int> t90 (90,empty,empty),
             t12 (12,t90,empty),
             t30 (30,empty,t12),
             t50 (50,empty,empty),
             t5  (5,t50, empty),
             t7  (7,t30,t5);



 std::ofstream f1 ("before.dot");
 t7.printDotty (f1);

 t7.fillGaps (0,5);

 std::ofstream f2 ("after.dot");
 t7.printDotty (f2);
}
Beispiel #3
0
void testmain(void) {
    print("function");

    expect(77, t1());
    t2(79);
    t3(1, 2, 3, 4, 5, 6);
    t4();
    t5();
    expect(3, t6());
    expect(12, t7(3, 4));
    t8(23);
    t9();
    expect(7, t10(3, 4.0));
    func_ptr_call();
    func_name();
    empty();
    empty2();
    test_bool();
    test_struct();
}
Beispiel #4
0
int main(void){

	printf("Running unit tests...\n");
	initArrays();
	t1();
	t2();
	t3();
	t4();
	t5();
	t6();
	t7();
	t8();
	t9();
	t10();
	t11();
	t12();
	t13();
	t14();

	return 1;
}
Beispiel #5
0
int main(){
    TreeNode t0(15);
    TreeNode t1(10);
    TreeNode t2(20);
    TreeNode t3(8);
    TreeNode t4(12);
    TreeNode t5(16);
    TreeNode t6(25);
    TreeNode t7(13);
    TreeNode t8(17);
    t0.left = &t1;
    t0.right = &t2;
    t1.left = &t3;
    t1.right = &t4;
    t2.left = &t5;
    t2.right = &t6;
    t4.right = &t7;
    t5.right = &t8;
    cout<<lca(&t0,&t3,&t7)->val<<endl;
    return 0;
}
int main() {
	TreeNode t1(1), t2(2), t3(3), t4(4), t5(5), t6(6), t7(7), t8(8), t9(9);
	t4.left = &t2;
	t4.right = &t5;

	t2.left = &t1;
	t2.right = &t3;

	t5.right = &t9;

	t9.left = &t7;
	t7.left = &t6;
	t7.right = &t8;
	
	Solution s;
	bool ret = s.isBalanced(&t4);
	
	printf("Return value is %s\n", ret ? "true":"false");

	return 0;
}
Beispiel #7
0
static const char*
ctor ()
{
  std::cout << __func__ << std::endl;

  ioa::time t1 (1, 500000);
  mu_assert (t1.sec () == 1);
  mu_assert (t1.usec () == 500000);

  ioa::time t2 (-1, 500000);
  mu_assert (t2.sec () == 0);
  mu_assert (t2.usec () == -500000);

  ioa::time t3 (1, -500000);
  mu_assert (t3.sec () == 0);
  mu_assert (t3.usec () == 500000);

  ioa::time t4 (-1, -500000);
  mu_assert (t4.sec () == -1);
  mu_assert (t4.usec () == -500000);

  ioa::time t5 (1, 5000000);
  mu_assert (t5.sec () == 6);
  mu_assert (t5.usec () == 0);

  ioa::time t6 (-1, 5000000);
  mu_assert (t6.sec () == 4);
  mu_assert (t6.usec () == 0);

  ioa::time t7 (1, -5000000);
  mu_assert (t7.sec () == -4);
  mu_assert (t7.usec () == 0);

  ioa::time t8 (-1, -5000000);
  mu_assert (t8.sec () == -6);
  mu_assert (t8.usec () == 0);

  return 0;
}
Beispiel #8
0
void testmain() {
    print("function");

    expect(77, t1());
    t2(79);
    t3(1, 2, 3, 4, 5, 6);
    t4();
    t5();
    expect(3, t6());
    expect(12, t7(3, 4));
    expect(77, (1 ? t1 : t6)());
    expect(3, (0 ? t1 : t6)());
    t8(23);
    t9();
    expect(7, t10(3, 4.0));
    func_ptr_call();
    func_name();
    local_static();
    empty();
    empty2();
    test_bool();
    test_struct();
    test_funcdesg();
}
Beispiel #9
0
//Define vertices and triangles
void CTitanic::init(float aScale)
	{
	this->clearMesh();

	TVector3 v0(-4,2,2);
	this->iVertices.push_back(v0*aScale);

	TVector3 v1(-3,1,0);
	this->iVertices.push_back(v1*aScale);

	TVector3 v2(-3,-1,0);
	this->iVertices.push_back(v2*aScale);

	TVector3 v3(-4,-2,2);
	this->iVertices.push_back(v3*aScale);

	TVector3 v4(3,2,2);
	this->iVertices.push_back(v4*aScale);

	TVector3 v5(3,1,0);
	this->iVertices.push_back(v5*aScale);

	TVector3 v6(3,-1,0);
	this->iVertices.push_back(v6*aScale);

	TVector3 v7(3,-2,2);
	this->iVertices.push_back(v7*aScale);

	TVector3 v8(5,0,2);
	this->iVertices.push_back(v8*aScale);

/*
	TTriangle t0(0,2,1);
	this->iTriangles.push_back(t0);


	TTriangle t1(0,3,2);
	this->iTriangles.push_back(t1);


	TTriangle t2(0,1,4);
	this->iTriangles.push_back(t2);


	TTriangle t3(1,5,4);
	this->iTriangles.push_back(t3);


	TTriangle t4(1,6,5);
	this->iTriangles.push_back(t4);


	TTriangle t5(1,2,6);
	this->iTriangles.push_back(t5);


	TTriangle t6(2,3,6);
	this->iTriangles.push_back(t6);


	TTriangle t7(3,7,6);
	this->iTriangles.push_back(t7);


	TTriangle t8(4,5,8);
	this->iTriangles.push_back(t8);


	TTriangle t9(5,6,8);
	this->iTriangles.push_back(t9);


	TTriangle t10(6,7,8);
	this->iTriangles.push_back(t10);


	TTriangle t11(0,4,3);
	this->iTriangles.push_back(t11);


	TTriangle t12(3,4,7);
	this->iTriangles.push_back(t12);


	TTriangle t13(4,8,7);
	this->iTriangles.push_back(t13);

*/

	TTriangle t0(0,1,2);
	this->iTriangles.push_back(t0);

	TTriangle t1(0,2,3);
	this->iTriangles.push_back(t1);

	TTriangle t2(0,4,1);
	this->iTriangles.push_back(t2);

	TTriangle t3(1,4,5);
	this->iTriangles.push_back(t3);

	TTriangle t4(1,5,6);
	this->iTriangles.push_back(t4);

	TTriangle t5(1,6,2);
	this->iTriangles.push_back(t5);

	TTriangle t6(2,6,3);
	this->iTriangles.push_back(t6);

	TTriangle t7(3,6,7);
	this->iTriangles.push_back(t7);

	TTriangle t8(4,8,5);
	this->iTriangles.push_back(t8);

	TTriangle t9(5,8,6);
	this->iTriangles.push_back(t9);

	TTriangle t10(6,8,7);
	this->iTriangles.push_back(t10);

	TTriangle t11(0,3,4);
	this->iTriangles.push_back(t11);

	TTriangle t12(3,7,4);
	this->iTriangles.push_back(t12);

	TTriangle t13(4,7,8);
	this->iTriangles.push_back(t13);
	}
Beispiel #10
0
int main() {

	/** Setup test environ */

	setupTestTree();
	
	std::vector<int16_t> v201501, v201502, v201503;
	/** (1420070400) NO_DATA (1420074000) 75 (1420077600) NO_DATA (1422748800) */
	for (int i = 0; i < 267840; ++i) {
		if (i < 360 || i > 720) v201501.push_back(-32768);
		else v201501.push_back(75);
	}
	for (int i = 0; i < 241920; ++i) {
		if (i > 720 && i < 1080) v201502.push_back(-32768);
		else v201502.push_back(85);

	}
	for (int i = 0; i < 267840; ++i) {
		if (i < 360) v201503.push_back(-32768);
		else v201503.push_back(95);
		//v201503.push_back(-32768);
	}

	createSzCacheFile("TestA/TestB/TestC/201501.szc", v201501);
	createSzCacheFile("TestA/TestB/TestC/201502.szc", v201502);
	createSzCacheFile("TestA/TestB/TestC/201503.szc", v201503);

	/** Test */

	SzCache szc("./",2);

	/** availableRange() */
	SzCache::SzRange szr = szc.availableRange();
	std::cout << "SzCache::availableRange(): (" << szr.first << "," << szr.second << ")\n";
	std::cout << "= ( " << time2str(szr.first) << " , " << time2str(szr.second) << " )\n";
	std::cout << "\n";

	SzCache::SzTime t1(1420070400 );
	SzCache::SzTime t2(1420070400 + 3600);
	SzCache::SzTime t3(1420070400 + 3600 + 3600);
	SzCache::SzTime t4(1420070400 + 2678400);
	SzCache::SzTime t5(1420070400 + 2678400 + 3600 + 3600);
	SzCache::SzTime t6(1420070400 + 2678400 + 3600 + 3600 + 3600);
	SzCache::SzTime t7(1420070400 + 2678400 + 2419200);
	SzCache::SzTime t8(1420070400 + 2678400 + 2419200 + 3600);
	SzCache::SzPath szp1("TestA/TestB/TestC");

	try {
		SzCache::SzSearchResult ssr = szc.searchInPlace(t1,szp1);
		std::cout << "SzCache::searchInPlace("<<t1<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t2,szp1);
		std::cout << "SzCache::searchInPlace("<<t2<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t2) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t2-10,szp1);
		std::cout << "SzCache::searchInPlace("<<t2-10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t3,szp1);
		std::cout << "SzCache::searchInPlace("<<t3<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t3) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t3+10,szp1);
		std::cout << "SzCache::searchInPlace("<<t3+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t4,szp1);
		std::cout << "SzCache::searchInPlace("<<t4<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t4) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t5,szp1);
		std::cout << "SzCache::searchInPlace("<<t5<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t5) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t5+10,szp1);
		std::cout << "SzCache::searchInPlace("<<t5+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t6,szp1);
		std::cout << "SzCache::searchInPlace("<<t6<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t6) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t6-10,szp1);
		std::cout << "SzCache::searchInPlace("<<t6-10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t7,szp1);
		std::cout << "SzCache::searchInPlace("<<t7<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t8,szp1);
		std::cout << "SzCache::searchInPlace("<<t8<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t8) throw std::logic_error("Assertion failed!");

		ssr = szc.searchInPlace(t8-10,szp1);
		std::cout << "SzCache::searchInPlace("<<t8-10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchRight(t2-50,t3,szp1); 
		std::cout << "SzCache::searcRight("<<t2-50<<","<<t3<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t2) throw std::logic_error("Assertion failed!");

		ssr = szc.searchRight(t2+50,t4,szp1); 
		std::cout << "SzCache::searcRight("<<t2+50<<","<<t4<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != (t2+50)) throw std::logic_error("Assertion failed!");
		
		ssr = szc.searchRight(t3+10,t3+50,szp1); 
		std::cout << "SzCache::searcRight("<<t3+10<<","<<t3+50<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchRight(t4-100,t5,szp1); 
		std::cout << "SzCache::searcRight("<<t4-100<<","<<t5<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != t4) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t7+100,t6,szp1); 
		std::cout << "SzCache::searchLeft("<<t7+100<<","<<t6<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != (t7-10)) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t6+100,t5,szp1); 
		std::cout << "SzCache::searchLeft("<<t6+100<<","<<t5<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != (t6+100)) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t3+100,t3+10,szp1); 
		std::cout << "SzCache::searchLeft("<<t3+100<<","<<t3+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");

		ssr = szc.searchLeft(t3+100,t3+10,szp1); 
		std::cout << "SzCache::searchLeft("<<t3+100<<","<<t3+10<<","<<szp1<<"):\n"
			<< "= ( " << std::get<0>(ssr) << " , " << std::get<1>(ssr) << " , " << std::get<2>(ssr) << " )\n\n";
		if(std::get<0>(ssr) != -1) throw std::logic_error("Assertion failed!");
		
		std::vector<int16_t> vals;
		
		SzCache::SzTime wtime = szc.writeData(vals, t2-50, t2+50, szp1);
		while( wtime < t2+50 ) 
			wtime = szc.writeData(vals, wtime, t2+50, szp1);
		std::cout << "writeData(" << t2-50 << "," << t2+50 << "):\n";
		for (unsigned int i = 0; i < vals.size(); i++) {
			std::cout << vals[i] << std::endl;
			if ((i < 5) && (vals[i] != SzCache::cSzCacheNoData))
				throw std::logic_error("Assertion failed!");
			if ((i > 5) && (vals[i] != 75))
				throw std::logic_error("Assertion failed!");
		}
		std::cout << std::endl;
		vals.clear();

		wtime = szc.writeData(vals, t4-50, t4+50, szp1);
		while( wtime < t4+50 ) 
			wtime = szc.writeData(vals, wtime, t4+50, szp1);
		std::cout << "writeData(" << t4-50 << "," << t4+50 << "):\n";
		for (unsigned int i = 0; i < vals.size(); i++) {
			std::cout << vals[i] << std::endl;	
			if ((i < 5) && (vals[i] != SzCache::cSzCacheNoData))
				throw std::logic_error("Assertion failed!");
			if ((i > 5) && (vals[i] != 85))
				throw std::logic_error("Assertion failed!");
		}
		std::cout << std::endl;
		vals.clear();

		wtime = szc.writeData(vals, t7-50, t7+50, szp1);
		while( wtime < t7+50 ) 
			wtime = szc.writeData(vals, wtime, t7+50, szp1);
		std::cout << "writeData(" << t7-50 << "," << t7+50 << "):\n";
		for (unsigned int i = 0; i < vals.size(); i++) {
			std::cout << vals[i] << std::endl;
			if ((i < 5) && (vals[i] != 85))
				throw std::logic_error("Assertion failed!");
			if ((i > 5) && (vals[i] != SzCache::cSzCacheNoData))
				throw std::logic_error("Assertion failed!");
		}
		std::cout << std::endl;
		vals.clear();

		

	} catch (std::logic_error& le) {
		removeSzCacheFile("TestA/TestB/TestC/201501.szc");
		removeSzCacheFile("TestA/TestB/TestC/201502.szc");
		removeSzCacheFile("TestA/TestB/TestC/201503.szc");
		removeTestTree();

		std::cout << "Assertion has failed!" << std::endl;
		return -1;
	}
		
	std::cout << "All assertions valid: Test PASSED" << std::endl;
	/** Remove test environ */

	removeSzCacheFile("TestA/TestB/TestC/201501.szc");
	removeSzCacheFile("TestA/TestB/TestC/201502.szc");
	removeSzCacheFile("TestA/TestB/TestC/201503.szc");
	removeTestTree();
	
	return 0;
}
Beispiel #11
0
		void URI::parse(){
			/*              hierarchycal-part
			 *          ____________|____________
			 *         /                         \
			 *   foo://example.com:8042/over/there?name=ferret#nose
      		 *   \_/   \______________/\_________/ \_________/ \__/
      		 *    |          |            |            |        |
      		 * scheme     authority     path          query   fragment
      		 *    |   ____________________|___
      		 *   / \ /                        \
      		 *   urn:example:animal:ferret:nose
      		 */
			size_t pos = 0;
			_scheme.clear();
			_port = -1;
			_path.clear();
			_fragment.clear();
			_query_string.clear();
			_param_string.clear();
			query.lock();
			query.clear();
			query.unlock();
			
			String hier_part;
			String non_hier_part;
			String __uri = _uri;
			
			pos = __uri.find(_scheme_div, 0);
			if(pos == __uri.npos){
				//Path is relative
				if(!__uri.startsWith("//")){
					__uri.insert(0, "//");
				}
				
			}
			else{
				_scheme = __uri.substr(0, pos + 1);
				__uri.biteLeft(pos + 1);
			}
			
			if(__uri.startsWith("//")){
				//Might be an URL
				__uri.biteLeft(2);
				if(__uri.find('?', 0) != __uri.npos){
					xvr2::Tokenizer t1(__uri, "?");
					hier_part = t1.next();
					non_hier_part = t1.next();
				}
				else if(__uri.find('#', 0) != __uri.npos){
					xvr2::Tokenizer t1(__uri, "#");
					hier_part = t1.next();
					non_hier_part = t1.next();
				}
				else{
					hier_part = __uri;
				}
				String address;
				//Now we got hierachical and non-hierarchical parts
				//Process hierarchical part
				if((pos = hier_part.find('/')) != hier_part.npos){
					address = hier_part.substr(0, pos);
					hier_part.biteLeft(pos);
					_path = hier_part;
				}
				else{
					address = hier_part;
				}
				if(address.size() > 0){
					String hostinfo;
					if((pos = address.find('@', 0)) != address.npos){
						Tokenizer t2(address, "@");
						String authinfo = t2.next();
						hostinfo = t2.next();
						if((pos = authinfo.find(':', 0)) == address.npos){
							_user = authinfo;
						}
						else{
							Tokenizer t3(authinfo, ":");
							_user = t3.next();
							_password = t3.next();
						}
					}
					else{
						_user.clear();
						_password.clear();
						hostinfo = address;
					}
					if(hostinfo.size() > 0){
						if(hostinfo.find(':', 0) == address.npos){
							//Only has the ip_address or hostname
							_host = hostinfo;
						}
						else{
							//Has hostname plus port information
							Tokenizer t4(hostinfo, ":");
							_host = t4.next();
							String tmpp = t4.next();
							_port = tmpp.toInt();
						}
					}
				}
				//TODO: Process non-hierarchical part
				if(non_hier_part.size() > 0){
					if(non_hier_part.find('#') == non_hier_part.npos){
						//Does not have a fragment
						_query_string = non_hier_part;
					}
					else{
						//Have a fragment
						Tokenizer t5(non_hier_part, "#");
						_query_string = t5.next();
						_fragment = t5.next();
					}
				}
				
				if(_path.find(';', 0) != _path.npos){
					//Has parameters, retrieve them
					Tokenizer t6(_path, ";");
					_path = t6.next();
					_param_string = t6.next();
				}
			}
			else{
				//Might be an URN
				throw xvr2::Net::URIParseException(_uri, "Resource is not a URI, looks more like a URN");
			}
			if(_scheme.size() > 0){
				_scheme.toLowerCase();
			}
			if(_port == -1){
				_scheme_port.lock();
				_port = _scheme_port[_scheme.c_str()];
				_scheme_port.unlock();
			}
			if(_query_string.size() > 0){
				//Fill in the query map
				Tokenizer t7(_query_string, "&");
				while(!t7.finished()){
					String q1 = t7.next();
					Tokenizer t8(q1, "=");
					try{
						String var = t8.next();
						String val = t8.next();
						query[var] = val;
					}
					catch(NoMoreTokens &nmt){
						StringBuffer sb;
						sb << "Malformed query in URI: " << q1; 
						throw URIParseException(_uri, sb.toString());
					}
				}
			}
		}
int main() {

	
	auto variance = 0;
	auto varianceSquared = 0;
	auto varianceSum = 0;
	auto standardDeviation = 0.0;
	std::vector<int> timeVector;
	std::vector<std::tuple<int, int, int>  > pixels;
	std::vector<std::tuple<int, int, int>  > pixels2;
	std::vector<std::tuple<int, int, int>  > pixels3;
	std::vector<std::tuple<int, int, int>  > pixels4;
	std::vector<std::tuple<int, int, int>  > pixels5;
	std::vector<std::tuple<int, int, int>  > pixels6;
	std::vector<std::tuple<int, int, int>  > pixels7;
	std::vector<std::tuple<int, int, int>  > pixels8;

	std::ofstream fout("output.ppm", std::ofstream::out);
	fout << "P3" << std::endl; // PPM file
	fout << imageWidth << " " << imageHeight << std::endl; //Image Dimensions
	fout << "256" << std::endl; // Max RGB pixel value

	std::cout << "Serial timing:" << std::endl;
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		std::thread t([&]() {drawMandelBrot(pixels, 0, imageHeight); });
		t.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}

	auto sum = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	auto average = sum / timeVector.size();

	for (auto n : timeVector) {
		variance = n - average;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "Serial timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		std::thread t([&]() {drawMandelBrot(pixels, 0, imageHeight); });
		t.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}

	auto sum10 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	auto average10 = sum10 / timeVector.size();

	for (auto n : timeVector) {
		variance = n - average10;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average10 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "2 Parallel Threads timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		pixels2.clear();
		std::thread t1([&]() {drawMandelBrot(pixels, 0, imageHeight / 2); });
		std::thread t2([&]() {drawMandelBrot(pixels2, (imageHeight / 2) + 1, imageHeight); });
		t1.join();
		t2.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}
	pixels.insert(pixels.end(), pixels2.begin(), pixels2.end());
	double sum2 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	double average2 = sum2 / timeVector.size();
	double speedUp2 = average / average2;
	double efficiency2 = speedUp2 / 2;

	for (auto n : timeVector) {
		variance = n - average2;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average2 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << "Speed Up: " << speedUp2 << std::endl;
	std::cout << "Efficiency: " << efficiency2 << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "3 Parallel Threads timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		pixels2.clear();
		pixels3.clear();
		std::thread t1([&]() {drawMandelBrot(pixels, 0, imageHeight / 3); });
		std::thread t2([&]() {drawMandelBrot(pixels2, ((imageHeight / 3) + 1), (imageHeight / 3) * 2 ); });
		std::thread t3([&]() {drawMandelBrot(pixels3, (((imageHeight / 3) * 2) + 1), imageHeight); });
		t1.join();
		t2.join();
		t3.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}
	
	pixels.insert(pixels.end(), pixels2.begin(), pixels2.end());	
	pixels.insert(pixels.end(), pixels3.begin(), pixels3.end());	
	double sum3 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	double average3 = sum3 / timeVector.size();
	double speedUp3 = average / average3;
	double efficiency3 = speedUp3 / 3;

	for (auto n : timeVector) {
		variance = n - average3;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average3 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << "Speed Up: " << speedUp3 << std::endl;
	std::cout << "Efficiency: " << efficiency3 << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "4 Parallel Threads timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		pixels2.clear();
		pixels3.clear();
		pixels4.clear();
		std::thread t1([&]() {drawMandelBrot(pixels, 0, imageHeight / 4); });
		std::thread t2([&]() {drawMandelBrot(pixels2, ((imageHeight / 4) + 1), imageHeight / 2); });
		std::thread t3([&]() {drawMandelBrot(pixels3, ((imageHeight / 2) + 1), (imageHeight / 4) * 3); });
		std::thread t4([&]() {drawMandelBrot(pixels4, (((imageHeight / 4) * 3) + 1), imageHeight); });
		t1.join();
		t2.join();
		t3.join();
		t4.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}

	pixels.insert(pixels.end(), pixels2.begin(), pixels2.end());
	pixels.insert(pixels.end(), pixels3.begin(), pixels3.end());
	pixels.insert(pixels.end(), pixels4.begin(), pixels4.end());
	double sum4 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	double average4 = sum4 / timeVector.size();
	double speedUp4 = average / average4;
	double efficiency4 = speedUp4 / 4;

	for (auto n : timeVector) {
		variance = n - average4;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average4 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << "Speed Up: " << speedUp4 << std::endl;
	std::cout << "Efficiency: " << efficiency4 << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "5 Parallel Threads timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		pixels2.clear();
		pixels3.clear();
		pixels4.clear();
		pixels5.clear();
		std::thread t1([&]() {drawMandelBrot(pixels, 0, imageHeight / 5); });
		std::thread t2([&]() {drawMandelBrot(pixels2, ((imageHeight / 5) + 1), (imageHeight / 5) * 2); });
		std::thread t3([&]() {drawMandelBrot(pixels3, (((imageHeight / 5) * 2)+ 1), (imageHeight / 5) * 3); });
		std::thread t4([&]() {drawMandelBrot(pixels4, (((imageHeight / 5) * 3) + 1), (imageHeight / 5) * 4); });
		std::thread t5([&]() {drawMandelBrot(pixels5, (((imageHeight / 5) * 4) + 1), imageHeight); });
		t1.join();
		t2.join();
		t3.join();
		t4.join();
		t5.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}

	pixels.insert(pixels.end(), pixels2.begin(), pixels2.end());
	pixels.insert(pixels.end(), pixels3.begin(), pixels3.end());
	pixels.insert(pixels.end(), pixels4.begin(), pixels4.end());
	pixels.insert(pixels.end(), pixels5.begin(), pixels5.end());
	double sum5 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	double average5 = sum5 / timeVector.size();
	double speedUp5 = average / average5;
	double efficiency5 = speedUp5 / 5;

	for (auto n : timeVector) {
		variance = n - average5;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average5 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << "Speed Up: " << speedUp5 << std::endl;
	std::cout << "Efficiency: " << efficiency5 << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "6 Parallel Threads timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		pixels2.clear();
		pixels3.clear();
		pixels4.clear();
		pixels5.clear();
		pixels6.clear();
		std::thread t1([&]() {drawMandelBrot(pixels, 0, imageHeight / 6); });
		std::thread t2([&]() {drawMandelBrot(pixels2, ((imageHeight / 6) + 1), imageHeight / 3); });
		std::thread t3([&]() {drawMandelBrot(pixels3, ((imageHeight / 3) + 1), (imageHeight / 2)); });
		std::thread t4([&]() {drawMandelBrot(pixels4, ((imageHeight / 2) + 1), (imageHeight / 3) * 2); });
		std::thread t5([&]() {drawMandelBrot(pixels5, (((imageHeight / 3) * 2) + 1), (imageHeight / 6) * 5); });
		std::thread t6([&]() {drawMandelBrot(pixels6, (((imageHeight / 6) * 5) + 1), imageHeight); });
		t1.join();
		t2.join();
		t3.join();
		t4.join();
		t5.join();
		t6.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}

	pixels.insert(pixels.end(), pixels2.begin(), pixels2.end());
	pixels.insert(pixels.end(), pixels3.begin(), pixels3.end());
	pixels.insert(pixels.end(), pixels4.begin(), pixels4.end());
	pixels.insert(pixels.end(), pixels5.begin(), pixels5.end());
	pixels.insert(pixels.end(), pixels6.begin(), pixels6.end());
	double sum6 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	double average6 = sum6 / timeVector.size();
	double speedUp6 = average / average6;
	double efficiency6 = speedUp6 / 6;

	for (auto n : timeVector) {
		variance = n - average6;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average6 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << "Speed Up: " << speedUp6 << std::endl;
	std::cout << "Efficiency: " << efficiency6 << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "7 Parallel Threads timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		pixels2.clear();
		pixels3.clear();
		pixels4.clear();
		pixels5.clear();
		pixels6.clear();
		pixels7.clear();
		std::thread t1([&]() {drawMandelBrot(pixels, 0, imageHeight / 7); });
		std::thread t2([&]() {drawMandelBrot(pixels2, ((imageHeight / 7) + 1), (imageHeight / 7) * 2); });
		std::thread t3([&]() {drawMandelBrot(pixels3, (((imageHeight / 7) * 2) + 1), (imageHeight / 7) * 3); });
		std::thread t4([&]() {drawMandelBrot(pixels4, (((imageHeight / 7) * 3) + 1), (imageHeight / 7) * 4); });
		std::thread t5([&]() {drawMandelBrot(pixels5, (((imageHeight / 7) * 4) + 1), (imageHeight / 7) * 5); });
		std::thread t6([&]() {drawMandelBrot(pixels6, (((imageHeight / 7) * 5) + 1), (imageHeight / 7) * 6); });
		std::thread t7([&]() {drawMandelBrot(pixels7, (((imageHeight / 7) * 6) + 1), imageHeight); });
		t1.join();
		t2.join();
		t3.join();
		t4.join();
		t5.join();
		t6.join();
		t7.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}

	pixels.insert(pixels.end(), pixels2.begin(), pixels2.end());
	pixels.insert(pixels.end(), pixels3.begin(), pixels3.end());
	pixels.insert(pixels.end(), pixels4.begin(), pixels4.end());
	pixels.insert(pixels.end(), pixels5.begin(), pixels5.end());
	pixels.insert(pixels.end(), pixels6.begin(), pixels6.end());
	pixels.insert(pixels.end(), pixels7.begin(), pixels7.end());
	double sum7 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	double average7 = sum7 / timeVector.size();
	double speedUp7 = average / average7;
	double efficiency7 = speedUp7 / 7;

	for (auto n : timeVector) {
		variance = n - average7;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average7 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << "Speed Up: " << speedUp7 << std::endl;
	std::cout << "Efficiency: " << efficiency7 << std::endl;
	std::cout << std::endl;

	//reset variables for accurate standard deviation
	variance = 0;
	varianceSquared = 0;
	varianceSum = 0;
	standardDeviation = 0.0;

	std::cout << "8 Parallel Threads timing:" << std::endl;
	timeVector.clear();
	for (int x = 0; x < 5; x++) {
		auto startTime = std::chrono::steady_clock::now();
		pixels.clear();
		pixels2.clear();
		pixels3.clear();
		pixels4.clear();
		pixels5.clear();
		pixels6.clear();
		pixels7.clear();
		pixels8.clear();
		std::thread t1([&]() {drawMandelBrot(pixels, 0, imageHeight / 8); });
		std::thread t2([&]() {drawMandelBrot(pixels2, ((imageHeight / 8) + 1), imageHeight / 4); });
		std::thread t3([&]() {drawMandelBrot(pixels3, ((imageHeight / 4) + 1), (imageHeight / 8) * 3); });
		std::thread t4([&]() {drawMandelBrot(pixels4, (((imageHeight / 8) * 3) + 1), (imageHeight / 8) * 4); });
		std::thread t5([&]() {drawMandelBrot(pixels5, (((imageHeight / 8) * 4) + 1), (imageHeight / 8) * 5); });
		std::thread t6([&]() {drawMandelBrot(pixels6, (((imageHeight / 8) * 5) + 1), (imageHeight / 8) * 6); });
		std::thread t7([&]() {drawMandelBrot(pixels7, (((imageHeight / 8) * 6) + 1), (imageHeight / 8) * 7); });
		std::thread t8([&]() {drawMandelBrot(pixels8, (((imageHeight / 8) * 7) + 1), imageHeight); });
		t1.join();
		t2.join();
		t3.join();
		t4.join();
		t5.join();
		t6.join();
		t7.join();
		t8.join();

		auto endTime = std::chrono::steady_clock::now();
		auto time = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);
		std::cout << int(time.count()) << " ms" << std::endl;
		timeVector.push_back(int(time.count()));
	}

	pixels.insert(pixels.end(), pixels2.begin(), pixels2.end());
	pixels.insert(pixels.end(), pixels3.begin(), pixels3.end());
	pixels.insert(pixels.end(), pixels4.begin(), pixels4.end());
	pixels.insert(pixels.end(), pixels5.begin(), pixels5.end());
	pixels.insert(pixels.end(), pixels6.begin(), pixels6.end());
	pixels.insert(pixels.end(), pixels7.begin(), pixels7.end());
	pixels.insert(pixels.end(), pixels8.begin(), pixels8.end());
	double sum8 = std::accumulate(timeVector.begin(), timeVector.end(), 0);
	double average8 = sum8 / timeVector.size();
	double speedUp8 = average / average8;
	double efficiency8 = speedUp8 / 8;

	for (auto n : timeVector) {
		variance = n - average8;
		varianceSquared = variance * variance;
		varianceSum += varianceSquared;
	}

	standardDeviation = sqrt(varianceSum / timeVector.size());
	std::cout << "Average: " << average8 << " ms" << std::endl;
	std::cout << "Standard Deviation: " << standardDeviation << " ms" << std::endl;
	std::cout << "Speed Up: " << speedUp8 << std::endl;
	std::cout << "Efficiency: " << efficiency8 << std::endl;
	std::cout << std::endl;
	std::cout << "Please wait: Writing to file" << std::endl;
	
	for (auto n : pixels) {
		fout << std::get<0>(n) << " " << std::get<1>(n) << " " << std::get<2>(n) << " ";
	}
	fout.close();

	std::cout << "Finished writing to file!" << std::endl;
	return 0;
}
Beispiel #13
0
void CIcosahedron::init( float s  ){

	this->clearMesh();
	float p = ((1.0 + sqrt(5.0))/2.0)*s;

	TVector3 v0(s,0.0,p);
	this->iVertices.push_back(v0);
	TVector3 v1(-s,0.0,p);
	this->iVertices.push_back(v1);
	TVector3 v2(s,0.0,-p);
	this->iVertices.push_back(v2);
	TVector3 v3(-s,0.0,-p);
	this->iVertices.push_back(v3);
	TVector3 v4(0.0,p,s);
	this->iVertices.push_back(v4);
	TVector3 v5(0,-p,s);
	this->iVertices.push_back(v5);
	TVector3 v6(0,p,-s);
	this->iVertices.push_back(v6);
	TVector3 v7(0.0,-p,-s);
	this->iVertices.push_back(v7);
	TVector3 v8(p,s,0.0);
	this->iVertices.push_back(v8);
	TVector3 v9(-p,s,0.0);
	this->iVertices.push_back(v9);
	TVector3 v10(p,-s,0.0);
	this->iVertices.push_back(v10);
	TVector3 v11(-p,-s,0.0);
	this->iVertices.push_back(v11);


	TTriangle t0(0,4,1);
	this->iTriangles.push_back(t0);

	TTriangle t1(0,1,5);
	this->iTriangles.push_back(t1);

	TTriangle t2(0,5,10);
	this->iTriangles.push_back(t2);

	TTriangle t3(0,10,8);
	this->iTriangles.push_back(t3);

	TTriangle t4(0,8,4);
	this->iTriangles.push_back(t4);

	TTriangle t5(4,8,6);
	this->iTriangles.push_back(t5);

	TTriangle t6(4,6,9);
	this->iTriangles.push_back(t6);

	TTriangle t7(4,9,1);
	this->iTriangles.push_back(t7);

	TTriangle t8(1,9,11);
	this->iTriangles.push_back(t8);

	TTriangle t9(1,11,5);
	this->iTriangles.push_back(t9);

	TTriangle t10(2,7,3);
	this->iTriangles.push_back(t10);

	TTriangle t11(2,3,6);
	this->iTriangles.push_back(t11);

	TTriangle t12(2,6,8);
	this->iTriangles.push_back(t12);

	TTriangle t13(2,8,10);
	this->iTriangles.push_back(t13);

	TTriangle t14(2,10,7);
	this->iTriangles.push_back(t14);

	TTriangle t15(7,10,5);
	this->iTriangles.push_back(t15);

	TTriangle t16(7,5,11);
	this->iTriangles.push_back(t16);

	TTriangle t17(7,11,3);
	this->iTriangles.push_back(t17);

	TTriangle t18(3,11,9);
	this->iTriangles.push_back(t18);

	TTriangle t19(3,9,6);
	this->iTriangles.push_back(t19);
	}
Beispiel #14
0
int main(int argc, char * const argv[])
{
        int opt_index, c;
        static struct option long_opts[] = {
                {"target", 1, 0, 0},
                {"dumpfile", 1, 0, 0},
                {"ssh", 1, 0, 0},
                {0, 0, 0, 0}
        };

        if (argc < 4 - (getenv(ENV_LUSTRE_MNTTGT)||getenv(ENV_LUSTRE_DUMPFILE)))
                usage(argv[0]);

        while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) {
                switch (c) {
                case 0: {
                        if (!optarg[0])
                                usage(argv[0]);

                        if (!strcmp(long_opts[opt_index].name, "target")) {
                                setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
                        } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
                                setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
                        } else if (!strcmp(long_opts[opt_index].name, "ssh")) {
                                safe_strncpy(ssh_cmd, optarg, MAX_STRING_SIZE);
                        } else
                                usage(argv[0]);
                        break;
                }
                case 's':
                        safe_strncpy(mds_server, optarg, MAX_STRING_SIZE);
                        break;
                case 'b':
                        safe_strncpy(barrier_script, optarg, MAX_STRING_SIZE);
                        break;
                case 'f':
                        safe_strncpy(failover_script, optarg, MAX_STRING_SIZE);
                        break;
                default:
                        usage(argv[0]);
                }
        }

        if (optind != argc)
                usage(argv[0]);
        if (!strlen(mds_server) || !strlen(barrier_script) ||
            !strlen(failover_script))
                usage(argv[0]);

        /* default to using ssh */
        if (!strlen(ssh_cmd)) {
                safe_strncpy(ssh_cmd, "ssh", MAX_STRING_SIZE);
        }

        test_ssh();

        /* prepare remote command */
        sprintf(barrier_cmd, "%s %s \"%s\"", 
                ssh_cmd, mds_server, barrier_script);
        sprintf(failover_cmd, "%s %s \"%s\"", 
                ssh_cmd, mds_server, failover_script);

        setenv(ENV_LUSTRE_TIMEOUT, "10", 1);

        __liblustre_setup_();

        t0();
        t1();
        t2a();
        t2b();
        t3a();
        t3b();
        t4();
        t5();
        t6();
        t7();
        t8();
        t9();
        t10();

	printf("liblustre is about shutdown\n");
        __liblustre_cleanup_();

	printf("complete successfully\n");
	return 0;
}
Beispiel #15
0
void t7_helper() {
  t7();
}