Example #1
0
static int run_tests(int argc, char **argv)
{
	struct result_info sum;
	int count = 0;
	int i;

	decoder = quirc_new();
	if (!decoder) {
		perror("quirc_new");
		return -1;
	}

	printf("  %-30s  %17s %11s\n", "", "Time (ms)", "Count");
	printf("  %-30s  %5s %5s %5s %5s %5s\n",
	       "Filename", "Load", "ID", "Total", "ID", "Dec");
	puts("----------------------------------------"
	     "---------------------------------------");

	memset(&sum, 0, sizeof(sum));
	for (i = 0; i < argc; i++) {
		struct result_info info;

		if (test_scan(argv[i], &info) > 0) {
			add_result(&sum, &info);
			count++;
		}
	}

	if (count > 1)
		print_result("TOTAL", &sum);

	quirc_destroy(decoder);
	return 0;
}
Example #2
0
int main()
{
    int elemnum = 1024 * 1024 * 16;
    clContext clCxt;
    getClContext(&clCxt);
    timeRcd.min_kerneltime=1000000;
    timeRcd.min_totaltime=1000000;
    test_scan(&clCxt,elemnum);
    printf("kernel min kernel time:%lf     ",timeRcd.min_kerneltime);
    printf("kernel min total time:%lf     \n",timeRcd.min_totaltime);
    return 0;
}
Example #3
0
static int scan_dir(const char *path, const char *filename,
		    struct result_info *info)
{
	DIR *d = opendir(path);
	struct dirent *ent;
	int count = 0;

	if (!d) {
		fprintf(stderr, "%s: opendir: %s\n", path, strerror(errno));
		return -1;
	}

	printf("%s:\n", path);

	while ((ent = readdir(d))) {
		if (ent->d_name[0] != '.') {
			char fullpath[1024];
			struct result_info sub;

			snprintf(fullpath, sizeof(fullpath), "%s/%s",
				 path, ent->d_name);
			if (test_scan(fullpath, &sub) > 0) {
				add_result(info, &sub);
				count++;
			}
		}
	}

	closedir(d);

	if (count > 1) {
		print_result(filename, info);
		puts("");
	}

	return count > 0;
}
Example #4
0
void BTreeTest::test4() {


	Status status;
	BTreeFile *btf;
	IndexFileScan* scan;

	int key, lokey, hikey;
	RID rid;
	int num = 1000;
	int num_deletes = 400;
	int i;
	dummy values[num];

	cout << "\n---------test4()  key type is Integer--------------\n";


	// test create()
	// if index exists, open it else create
	btf = new BTreeFile(status, "BTreeIndex", attrInteger, sizeof(int));
	if (status != OK) {
		minibase_errors.show_errors();
		exit(1);
	}
	cout << "\nBTreeIndex created successfully." << endl << endl;


	cout << " Creating " << num << " random entries" << endl;

	for ( i = 0; i < num; i++) {
		values[i].key = i * 8 + (rand() % 8);
		values[i].r.pageNo = i;
		values[i].r.slotNo = i+1;
		values[i].sort_value1 = rand() % 1000000;
		values[i].sort_value2 = rand() % 1000000;

		/*cout << " key " << values[i].key
			<< " sort_value1 " << values[i].sort_value1
			<< " sort_value2 " << values[i].sort_value2 << endl;*/

	}

	// test insert()

	// put values in insertion order
	qsort( values, num, sizeof(dummy), eval1);

	cout << "\n------Start to insert " << num << "  records------" << endl;

	for (i=0; i < num; i++){
		//cout << " Inserting key " << values[i].key << " order " 
		//<< values[i].sort_value1 << endl;
		if (btf->insert(&(values[i].key), values[i].r) != OK) {
			minibase_errors.show_errors();
		}
	}
	cout << "\n------ End of insert------" << endl;



	// test delete()
	cout << "\n\n------ Delete the first " << num_deletes 
		<< " of the records-----" << endl;

	// place records in deletion order
	qsort(values, num, sizeof(dummy), eval2);

	for (i = 0; i < num_deletes; i++) {
		/*
		   cout << "Deleting record with key = " << values[i].key 
		   << "  [pageNo,slotNo] = ";
		   cout << "[" << values[i].r.pageNo<<","
		   << values[i].r.slotNo << "]" <<endl;
		   */
		if (btf->Delete(&values[i].key, values[i].r) != OK) {
			minibase_errors.show_errors();
		}
	}
	cout << "Deleted  " << i << "  records " << endl;
	cout << "\n------ End of delete ------" << endl;

	delete btf;

	btf = new BTreeFile(status, "BTreeIndex");

	// test scan and delete_current()
	cout << "\n\n------ Testing scans ------" << endl;
	lokey = 570;
	hikey = 690;
	i= 1000;
	while (i < 1020){
		rid.pageNo = i;
		rid.slotNo = i+ 1;
		if(i < 1010) 
			key = lokey;
		else 
			key = hikey;

		if(btf->insert(&key,rid) != OK)
			minibase_errors.show_errors();
		i++;
	}

	//AllScan
	scan = btf->new_scan(NULL,NULL);
	cout << "\n\n------Start AllScan------" << endl;

	test_scan(scan);
	delete scan;   

	cout << "\n------End of AllScan------" << endl;

	//MaxRangeScan
	scan = btf->new_scan(NULL, &hikey);
	cout << "\n\n------Start MaxRangeScan with hikey = "<<hikey<<"------\n";
	test_scan(scan);
	delete scan;

	cout << "\n------End of MaxRangeScan with hikey = "<<hikey<<"------\n";

	//MinRangeScan;
	scan = btf->new_scan(&lokey, NULL);
	cout << "\n\n------Start MinRangeScan with lokey = "<<lokey<<"------\n";
	test_scan(scan);
	delete scan;   

	cout << "\n------End of MinRangeScan with lokey = "<<lokey<<"------\n";

	//ExactMatch
	scan = btf->new_scan(&hikey, &hikey);
	cout << "\n\n------Start ExactMatch with key = " <<hikey <<"-------\n";
	test_scan(scan);
	delete scan;
	cout << "\n------End of ExactMatch with key = " <<hikey <<"-------\n";


	//MinMaxRangeScan with delete_current()
	scan = btf->new_scan(&lokey, &hikey);
	cout << "\n\n------Start MinMaxRangeScan with lokey = "<<lokey  << " hikey = "<<hikey<<"------\n";
	cout << "Will also perform delete_current()\n";

	int count = 0;
	status = OK;
	while (status == OK) {
		char* temp = new char[scan->keysize()];    // BK
		if ((status = scan->get_next(rid, temp)) == OK)  {
			count++;
			if ((status = scan->delete_current()) == OK) {
				cout << "Record with [pageNo,slotNo] = ";
				cout << "[" << rid.pageNo<<","<<rid.slotNo<<"] deleted"<<endl;
			} else {
				cout << "Failure to delete record...\n";
				minibase_errors.show_errors();
			}
			delete [] temp;  // BK
		}
	}

	if (status != DONE) {
		cout << "Something is wrong in test4\n";
		minibase_errors.show_errors();
	}

	cout << "Number of records scanned = " << count << endl;
	cout << "\n------End of MinMaxRangeScan -----------------------\n";
	delete scan;

	delete btf;

	// test destroyFile()
	cout << "\n\n-----------Destroying index----------\n";

	btf = new BTreeFile(status, "BTreeIndex");

	cout << "\n-------Start to destroy the index----------" << endl;
	status = btf->destroyFile();
	if (status != OK)
		minibase_errors.show_errors();

	delete btf;

	cout << "\n--------- End of destroying the index -----" <<endl;
	cout << "\n\n--------- End of test4   -------------" <<endl;
}
Example #5
0
void BTreeTest::test3() {

	cout << "\n--------test3() key type is String---------\n";

	Status status;
	BTreeFile *btf;
	IndexFileScan* scan;

	int keysize = MAX_KEY_SIZE1;
	char*  key = new char[keysize];
	char*  lokey = new char[keysize];
	char*  hikey = new char[keysize];
	int	i = 0;
	RID rid, lorid;
	ifstream keysamples;

	keysamples.open("keys",ios::in);
	if (!keysamples) {
		cout << "keys not found.\n";
		cout << " there is a copy in $MINIBASE_HOME/programs/minibase "<< endl;
		return;
	}


	// test create()
	btf = new BTreeFile(status, "BTreeIndex", attrString, keysize);
	if (status != OK) {
		minibase_errors.show_errors();
		exit(1);
	}
	cout << "BTreeIndex created successfully." << endl;


	// test insert()
	cout << "\n------Start to insert records--------" << endl;

	keysamples.getline(key, keysize, '\n');
	while(!keysamples.eof()) {
		rid.pageNo = (int)(key[0]+key[1]+key[2]);
		rid.slotNo = rid.pageNo;
		if (btf->insert(key, rid) != OK) {
			minibase_errors.show_errors();
		}

		i++;
		if(i==20) strncpy(lokey,key,keysize);
		if(i==100) strncpy(hikey,key,keysize);
		keysamples.getline(key, keysize, '\n');
	}
	cout << "\nNumber of records inserted is " << i << endl;
	cout << "\n--------------End of insert----------------" << endl;

	// test delete()
	cout << "\n------Start to delete some records----------" << endl;

	// delete the lokey
	lorid.pageNo = (int)(lokey[0]+lokey[1]+lokey[2]);
	lorid.slotNo = lorid.pageNo;

	if (btf->Delete(lokey, lorid) != OK)
		minibase_errors.show_errors();
	else
		cout << "\nSuccessfully deleted record with key = " << lokey << endl;
	cout << "\n---------------End of delete----------------" << endl;

	delete btf;
	btf = new BTreeFile(status, "BTreeIndex");

	// test scan and delete_current
	//AllScan     
	scan = btf->new_scan(NULL,NULL);                                            
	cout << "\n---------------Start AllScan------------" << endl;
	test_scan(scan);                                                            
	delete scan;                                                                
	cout <<"\n------End of AllScan------" << endl;

	//MaxRangeScan                                                              
	scan = btf->new_scan(NULL, hikey);                                       
	cout << "\n\n------Start MaxRangeScan with hikey = "<<hikey<< "------\n";
	test_scan(scan);     
	delete scan;                                                                
	cout << "\n------End of MaxRangeScan with hikey = "<<hikey<< "------\n";


	//MinRangeScan;                                                        
	scan = btf->new_scan(lokey, NULL);                                         
	cout << "\n\n-----Start MinRangeScan with lokey = "<<lokey<< "------\n"; 
	test_scan(scan);                                                            
	delete scan;                                                                
	cout << "\n------End of MinRangeScan with lokey = "<<lokey<< "------\n"; 

	//ExactMatch                                                                
	scan = btf->new_scan(hikey, hikey);                                       
	cout << "\n\n------Start ExactMatch with key = " <<hikey << "------\n"; 
	test_scan(scan);                                                            
	delete scan;
	cout << "\n------End of ExactMatch with key = " <<hikey << "------\n"; 

	//MinMaxRangeScan
	scan = btf->new_scan(lokey, hikey);
	cout << "\n\n------Start MinMaxRangeScan------" << endl;
	if(scan == NULL) {
		cout << "Cannot open a scan." << endl;
	}

	cout << "\n------Start scan with lokey = "<<lokey << " hikey = "<<hikey << "-----" << endl;

	int count = 0;
	status = OK;
	while (status == OK) {
		char* temp = new char[scan->keysize()];   // BK
		if ((status = scan->get_next(rid, temp)) == OK)  {
			count++;
			if ((status = scan->delete_current()) == OK) {
				cout << "Record with [pageNo,slotNo] = ";
				cout << "[" << rid.pageNo<<","<<rid.slotNo<<"] deleted"<<endl;
			}
			else
				minibase_errors.show_errors();
		}
		delete [] temp;  // BK
	}

	if (status != DONE)
	{
		cout << "Problem...\n";
		minibase_errors.show_errors();
	}
	cout << "Number of records scanned = " << count << endl;
	cout << "\n-------End of MinMaxRangeScan------\n";
	delete scan;


	cout << "\n\n------Testing abnormal scans------\n";

	// test abnormal scans
	// lokey > hikey
	strcpy(lokey, "zabcd");
	strcpy(hikey, "abcde");
	scan = btf->new_scan(lokey, hikey);

	char *temp1 = new char[MAX_KEY_SIZE1];
	if ((status = scan->get_next(rid, temp1)) == OK) {
		cout << " Error: find next??? nothing to find!!" << endl;
		minibase_errors.show_errors();
		exit(1);
	}

	if (status != DONE)
		minibase_errors.show_errors();
	delete scan;

	cout << " Failed as expected: no records scanned " << endl;

	// lokey > the largest key 
	strcpy(lokey, "zabcd");
	strcpy(hikey, "zcdef");
	scan = btf->new_scan(lokey, hikey);
	if ((status = scan->get_next(rid, temp1)) == OK) {
		cout << " Error: find next??? nothing to find!!" << endl;
		minibase_errors.show_errors();
		exit(1);
	}

	if (status != DONE)
		minibase_errors.show_errors();
	delete scan;

	cout << " Failed as expected: no records scanned " << endl;

	// hikey < smallest key
	strcpy(lokey, "aaa");
	strcpy(hikey, "aaaaa");
	scan = btf->new_scan(lokey, hikey);
	cout << "\n----Start MinMaxRangeScan with lokey = " << lokey ;
	cout << " hikey = " << hikey << "-------\n" ;
	cout << " -------hikey is smaller than the smallest key" << endl;

	if ((status = scan->get_next(rid, temp1)) == OK) {
		cout << " Error: find next??? nothing to find!!" << endl;
		minibase_errors.show_errors();
		exit(1);
	}

	if (status != DONE)
		minibase_errors.show_errors();
	delete scan;

	cout << " Failed as expected: no records scanned " << endl;

	delete temp1; 
	delete btf;

	// test destroyFile()

	btf = new BTreeFile(status, "BTreeIndex");

	cout << "-------Start to destroy the index-----------" << endl;
	status = btf->destroyFile();
	if (status != OK)
		minibase_errors.show_errors();
	cout << "-------End to destroy the index-----------" << endl;

	delete btf;
	delete key;
	delete lokey;
	delete hikey;
	cout << "\n\n---------End of Test 3 ---------------------\n\n";
}
Example #6
0
void BTreeTest::test1() {

	cout << "\n---------test1()  key type is Integer--random------\n";

	Status status;
	BTreeFile *btf;
	IndexFileScan* scan;

	int key, lokey, hikey,i;
	RID rid;
	int num;


	// test create()
	// if index exists, open it else create
	btf = new BTreeFile(status, "BTreeIndex", attrInteger, sizeof(int));
	if (status != OK) {
		minibase_errors.show_errors();
		exit(1);
	}
	cout << "BTreeIndex created successfully." << endl << endl;


	// test insert()
	num = 2000;

	struct dummy{
		RID r;
		int key;
	};

	cout << "\nstart BTreeIndex insertion" << endl << endl;
	dummy kill[410];
	for (i = 0; i < num; i++) {
		rid.pageNo = i; rid.slotNo = i+1;
		key = num - i; 

		if (i % 10 == 0) {
			kill[(i/10)].r.pageNo = rid.pageNo;
			kill[(i/10)].r.slotNo = rid.slotNo;
			kill[i/10].key = key;
		}

		if (btf->insert(&key, rid) != OK) {
			cout << "Inserting record with key = " << key << "  [pageNo,slotNo] = ";
			cout << "[" << rid.pageNo<<","<<rid.slotNo<<"] failed!!\n" <<endl;
			minibase_errors.show_errors();
		}
	}

	// test delete()

	cout << "\nstart BTreeIndex deletion" << endl << endl;
	int j = 0;
	for (i = 0; i < num; i++) {
		if (i % 10 == 0) {
			j++;
			if (btf->Delete(&kill[i/10].key, kill[(i/10)].r) != OK) {
				cout << " Deleting record with key = " << kill[i/10].key << "  [pageNo,slotNo] = ";
				cout << "[" << kill[i/10].r.pageNo<<","<<kill[i/10].r.slotNo<<"] failed !!"<<endl;
				minibase_errors.show_errors();
			}
		}
	}

	delete btf;

	btf = new BTreeFile(status, "BTreeIndex");
	if(status == OK)
		cout<<"\n BTreeIndex opened successfully." << endl << endl;

	// test scan and delete_current()
	cout << "\n----------- Testing scans -------------" << endl;
	lokey = 200;
	hikey = 400;

	//AllScan
	scan = btf->new_scan(NULL,NULL);
	test_scan(scan);
	delete scan;   


	//MaxRangeScan
	scan = btf->new_scan(NULL, &hikey);
	test_scan(scan);
	delete scan;



	//MinRangeScan;
	scan = btf->new_scan(&lokey, NULL);
	test_scan(scan);
	delete scan;   


	//ExactMatch
	scan = btf->new_scan(&hikey, &hikey);
	test_scan(scan);
	delete scan;



	//MinMaxRangeScan with delete_current()
	scan = btf->new_scan(&lokey, &hikey);
	int count = 0;
	int size = scan->keysize();
	char* temp = new char[size];
	int* ikey;
	char* ckey;

	status = OK;

	while (status == OK) {
		if ((status = scan->get_next(rid, temp)) == OK)  {
			count++;
			if ((status = scan->delete_current()) == OK) {
				cout << "Record with [pageNo,slotNo] = ";
				cout << "[" << rid.pageNo<<","<<rid.slotNo<<"]"; 
				if (size == sizeof(int)) {
					ikey = (int *) temp;
					cout << "\tkey = " << *ikey;
				} else {
					ckey = (char*) temp;
					cout <<"\t key = " << ckey;
				}
				cout << "\tdeleted !!" <<endl; 
			} else {
				cout << "Failure to delete record...\n";
				minibase_errors.show_errors();
			}
		}
		else if (status != DONE)
			minibase_errors.show_errors();
	}

	delete [] temp;  

	if (status != DONE) {
		cout << "Something is wrong in test1\n";
		minibase_errors.show_errors();
	}

	//    delete scan;

	delete btf;

	cout << "\n---------------End of Test 1----------------------\n\n";
}
Example #7
0
int
main (void)
{
  parser = NULL;
  int i, j, k;
  int request_count;
  int response_count;

  printf("sizeof(http_parser) = %d\n", sizeof(http_parser));

  for (request_count = 0; requests[request_count].name; request_count++);
  for (response_count = 0; responses[response_count].name; response_count++);

  //// RESPONSES

  for (i = 0; i < response_count; i++) {
    test_message(&responses[i]);
  }

  for (i = 0; i < response_count; i++) {
    if (!responses[i].should_keep_alive) continue;
    for (j = 0; j < response_count; j++) {
      if (!responses[j].should_keep_alive) continue;
      for (k = 0; k < response_count; k++) {
        test_multiple3(&responses[i], &responses[j], &responses[k]);
      }
    }
  }

  printf("response scan 1/1      ");
  test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY]
           , &responses[NO_HEADERS_NO_BODY_404]
           , &responses[NO_REASON_PHRASE]
           );

  puts("responses okay");


  /// REQUESTS


  test_error("hello world");
  test_error("GET / HTP/1.1\r\n\r\n");

  const char *dumbfuck2 =
    "GET / HTTP/1.1\r\n"
    "X-SSL-Bullshit:   -----BEGIN CERTIFICATE-----\r\n"
    "\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n"
    "\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n"
    "\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n"
    "\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n"
    "\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n"
    "\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n"
    "\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n"
    "\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n"
    "\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n"
    "\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n"
    "\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\r\n"
    "\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\r\n"
    "\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgHTTPAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\r\n"
    "\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\r\n"
    "\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\r\n"
    "\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\r\n"
    "\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\r\n"
    "\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\r\n"
    "\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\r\n"
    "\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\r\n"
    "\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\r\n"
    "\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\r\n"
    "\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\r\n"
    "\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\r\n"
    "\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\r\n"
    "\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n"
    "\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n"
    "\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n"
    "\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n"
    "\tRA==\r\n"
    "\t-----END CERTIFICATE-----\r\n"
    "\r\n";
  test_error(dumbfuck2);

#if 0
  // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body
  // until EOF.
  //
  // no content-length
  // error if there is a body without content length
  const char *bad_get_no_headers_no_body = "GET /bad_get_no_headers_no_body/world HTTP/1.1\r\n"
                                           "Accept: */*\r\n"
                                           "\r\n"
                                           "HELLO";
  test_error(bad_get_no_headers_no_body);
#endif
  /* TODO sending junk and large headers gets rejected */


  /* check to make sure our predefined requests are okay */
  for (i = 0; requests[i].name; i++) {
    test_message(&requests[i]);
  }



  for (i = 0; i < request_count; i++) {
    if (!requests[i].should_keep_alive) continue;
    for (j = 0; j < request_count; j++) {
      if (!requests[j].should_keep_alive) continue;
      for (k = 0; k < request_count; k++) {
        test_multiple3(&requests[i], &requests[j], &requests[k]);
      }
    }
  }

  printf("request scan 1/3      ");
  test_scan( &requests[GET_NO_HEADERS_NO_BODY]
           , &requests[GET_ONE_HEADER_NO_BODY]
           , &requests[GET_NO_HEADERS_NO_BODY]
           );

  printf("request scan 2/3      ");
  test_scan( &requests[POST_CHUNKED_ALL_YOUR_BASE]
           , &requests[POST_IDENTITY_BODY_WORLD]
           , &requests[GET_FUNKY_CONTENT_LENGTH]
           );

  printf("request scan 3/3      ");
  test_scan( &requests[TWO_CHUNKS_MULT_ZERO_END]
           , &requests[CHUNKED_W_TRAILING_HEADERS]
           , &requests[CHUNKED_W_BULLSHIT_AFTER_LENGTH]
           );

  puts("requests okay");

  return 0;
}
void
selftest(void)
{
	// for handling "errout"

	if (setjmp(jbuf))
		return;

#if SELFTEST

	test_low_level();

	test_multiply();
	test_scan();
	test_power();
	test_factor_number();
	test_test();
	test_tensor();

	test_bake();

	test(__FILE__, s, sizeof (s) / sizeof (char *)); // "s" is in selftest.h

	test_abs();
	test_adj();
	test_arg();
	test_besselj();
	test_bessely();
	test_ceiling();
	test_choose();
	test_circexp();
	test_clock();
	test_cofactor();
	test_condense();
	test_contract();
	test_defint();
	test_denominator();
	test_derivative();
	test_dirac();
	test_erf();
	test_erfc();
	test_expand();
	test_expcos();
	test_expsin();
	test_factorpoly();
	test_float();
	test_floor();
	test_gamma();
	test_gcd();
	test_imag();
	test_inner();
	test_lcm();
	test_log();
	test_mag();
	test_mod();
	test_nroots();
	test_numerator();
	test_outer();
	test_polar();
	test_quotient();
	test_rationalize();
	test_real();
	test_rect();
	test_sgn();
	test_taylor();
	test_transpose();
	test_zero();

	test_hermite();
	test_laguerre();
	test_legendre();
	test_binomial();
	test_divisors();
	test_coeff();
	test_sin();
	test_cos();
	test_tan();
	test_sinh();
	test_cosh();
	test_tanh();
	test_arcsin();
	test_arcsinh();
	test_arccos();
	test_arccosh();
	test_arctan();
	test_arctanh();
	test_index();
	test_isprime();
	test_integral();
	test_simplify();
	test_roots();
	test_eigen();

#endif

	mini_test();

	logout("OK, all tests passed.\n");
}