Beispiel #1
0
static void uart1_driver_task(void *pvParameters)
{
    unsigned int test_count = 0;
    const TickType_t xTicksToWait = 1000 / portTICK_PERIOD_MS; //delay 1s
    /* Just to stop compiler warnings. */
    ( void ) pvParameters;

    udprintf("\r\n[TEST] uart1_driver_task running...");
    for (;;)
    {
        TEST_INFO(">>uart1_driver_task :%d",test_count++);
        TEST_INFO(">>totoal read count=%d",test_uart1_rx_count);
        vTaskDelay(xTicksToWait);
    }
}
Beispiel #2
0
TEST(GdbmDBTest, BasicTest) {
    log_init(LL_ALL, "gdbmdb", "./log");
    EXPECT_TRUE(true);
    GdbmDB gdbmDb;
    gdbmDb.open("./db.gdbm");
    std::string value;
    std::string key = "key123";
    int status = gdbmDb.put(key, "value123");
    EXPECT_EQ(status, 0);
    status = gdbmDb.get(key, value);
    EXPECT_EQ(status, 0);
    EXPECT_EQ(value, "value123");
    EXPECT_EQ(gdbmDb.exist(key), true);
    gdbmDb.put("k2", "v2");
    EXPECT_EQ(gdbmDb.dbCount(), 2);
    std::map<string, string> keyVals;

    gdbmDb.dump(keyVals);
    for (std::map<string, string>::iterator it = keyVals.begin();
        it != keyVals.end(); ++it) {
        TEST_INFO("key:%s, value:%s",
            it->first.c_str(), it->second.c_str());
    }
    status = gdbmDb.dump("to.gdbm.new", 1);
    EXPECT_EQ(status, 0);
    status = gdbmDb.load("to.gdbm.new");
    EXPECT_EQ(status, 0);
    EXPECT_EQ(gdbmDb.dbCount(), 2);
    status = gdbmDb.del(key);
    EXPECT_EQ(status, 0);
}
Beispiel #3
0
TEST(TcbDBTest, BasicTest) {
    EXPECT_TRUE(true);
    TcbDB tcbDb;
    tcbDb.open("./tcb.db");
    std::string value;
    std::string key = "key123";
    int status = tcbDb.put(key, "value123");
    EXPECT_EQ(status, 0);
    status = tcbDb.get(key, value);
    EXPECT_EQ(status, 0);
    EXPECT_EQ(value, "value123");
    TcbDB toDb;
    status = tcbDb.copy("./tcb.new.db");
    toDb.open("./tcb.new.db");
    EXPECT_EQ(status, 0);
    value = "";
    toDb.get(key, value);
    EXPECT_EQ(value, "value123");
    tcbDb.append(key, "value123");
    status = tcbDb.get(key, value);
    EXPECT_EQ(status, 0);
    EXPECT_EQ(value, "value123value123");
    status = tcbDb.putDup(key, "v2");
    EXPECT_EQ(status, 0);
    EXPECT_EQ(16, tcbDb.valueSizeOfKey(key));
    std::vector<std::string> values;
    tcbDb.getPrefix("key", 2, values);
    EXPECT_EQ(64, values.size());
    EXPECT_EQ(values[0], "key123");
    EXPECT_EQ(2, tcbDb.keyCounts());

    TEST_INFO("db size:%d", tcbDb.dbSize());
    tcbDb.put("k1", "v1");
    tcbDb.put("k2", "v2");
    tcbDb.put("k3", "v3");
    tcbDb.put("k4", "v4");
    EXPECT_EQ(6, tcbDb.keyCounts());
    values.clear();
    tcbDb.multiGet("k", "l", 10, values);
    for (size_t ii = 0; ii < values.size(); ++ii) {
        TEST_INFO("id:%d,value:%s", ii, values[ii].c_str());
    }
    status = tcbDb.del(key);
    EXPECT_EQ(status, 0);
    tcbDb.destory();
    toDb.destory();
}
Beispiel #4
0
int main(int _argc, const char *_argv[]) {
	etk::init(_argc, _argv);
	enet::init(_argc, _argv);
	for (int32_t iii=0; iii<_argc ; ++iii) {
		std::string data = _argv[iii];
		if (    data == "-h"
		     || data == "--help") {
			TEST_PRINT(etk::getApplicationName() << " - help : ");
			TEST_PRINT("    " << _argv[0] << " [options]");
			TEST_PRINT("        No options ...");
			return -1;
		}
	}
	TEST_INFO("==================================");
	TEST_INFO("== Test TCP server              ==");
	TEST_INFO("==================================");
	//Wait on TCP connection:
	enet::TcpServer interface;
	// Configure server interface:
	interface.setHostNane("127.0.0.1");
	interface.setPort(12345);
	// Start listening ...
	interface.link();
	// Wait a new connection ..
	enet::Tcp tcpConnection = std::move(interface.waitNext());
	// Free Connected port
	interface.unlink();
	
	int32_t iii = 0;
	while (tcpConnection.getConnectionStatus() == enet::Tcp::status::link) {
		int32_t len = tcpConnection.write("plop" + etk::to_string(iii));
		TEST_INFO("write len=" << len);
		char data[1024];
		len = tcpConnection.read(data, 1024);
		if (len > 0) {
			TEST_INFO("read len=" << len << " data='" << data << "'");
		}
		iii++;
	}
	if (iii>=1000000) {
		TEST_INFO("auto disconnected");
	} else if (tcpConnection.getConnectionStatus() != enet::Tcp::status::link) {
		TEST_INFO("server disconnected");
	} else {
		TEST_INFO("ERROR disconnected");
	}
	if (tcpConnection.unlink() == false) {
		TEST_ERROR("can not unlink to the socket...");
		return -1;
	}
	return 0;
}
Beispiel #5
0
static void uart1_unpack_task(void *pvParameters)
{
    int rLen = 0;
    char rBuf[64];
    EventBits_t uxBits;
    const TickType_t xTicksToWait = 100 / portTICK_PERIOD_MS;
    
	/* Just to stop compiler warnings. */
	( void ) pvParameters;
    
    udprintf("\r\n[TEST] uart1_unpack_task running...");
    for (;;)
    {
//        udprintf("\r\n>>uart1_unpack_task Testing...");
		uxBits = xEventGroupWaitBits(
					xUart1RxEventGroup,	// The event group being tested.
					UART_DMA_RX_COMPLETE_EVENT_BIT \
					| UART_DMA_RX_INCOMPLETE_EVENT_BIT,	// The bits within the event group to wait for.
					pdTRUE,			// BIT_COMPLETE and BIT_TIMEOUT should be cleared before returning.
					pdFALSE,		// Don't wait for both bits, either bit will do.
					xTicksToWait );	// Wait a maximum of 100ms for either bit to be set.

		if( ( uxBits & UART_DMA_RX_COMPLETE_EVENT_BIT ) != 0 )
		{
            rLen = Uart1Read(rBuf, sizeof(rBuf));
            test_uart1_rx_count += rLen;
            TEST_INFO("Uart1Read COMPLETE rLen=%d",rLen);
		}
		else if( ( uxBits & UART_DMA_RX_INCOMPLETE_EVENT_BIT ) != 0 )
		{
            rLen = Uart1Read(rBuf, sizeof(rBuf));
            test_uart1_rx_count += rLen;
            TEST_INFO("Uart1Read INCOMPLETE rLen=%d",rLen);
		}
		else
		{
		}
    }
}
Beispiel #6
0
int main(int _argc, const char** _argv) {
	// the only one init for etk:
	etk::init(_argc, _argv);
	std::string inputName = "";
	bool performance = false;
	bool perf = false;
	int64_t sampleRate = 48000;
	for (int32_t iii=0; iii<_argc ; ++iii) {
		std::string data = _argv[iii];
		if (etk::start_with(data,"--in=")) {
			inputName = &data[5];
		} else if (data == "--performance") {
			performance = true;
		} else if (data == "--perf") {
			perf = true;
		} else if (etk::start_with(data,"--sample-rate=")) {
			data = &data[14];
			sampleRate = etk::string_to_int32_t(data);
		} else if (    data == "-h"
		            || data == "--help") {
			TEST_PRINT("Help : ");
			TEST_PRINT("    ./xxx --fb=file.raw --mic=file.raw");
			TEST_PRINT("        --in=YYY.raw        inout file");
			TEST_PRINT("        --performance       Generate signal to force algo to maximum process time");
			TEST_PRINT("        --perf              Enable performence test (little slower but real performence test)");
			TEST_PRINT("        --sample-rate=XXXX  Signal sample rate (default 48000)");
			exit(0);
		}
	}
	// PERFORMANCE test only ....
	if (performance == true) {
		performanceCompressor();
		performanceLimiter();
		performanceGate();
		return 0;
	}
	if (inputName == "") {
		TEST_ERROR("Can not Process missing parameters...");
		exit(-1);
	}
	TEST_INFO("Read input:");
	std::vector<double> inputData = convert(etk::FSNodeReadAllDataType<int16_t>(inputName));
	TEST_INFO("    " << inputData.size() << " samples");
	// resize output :
	std::vector<double> output;
	output.resize(inputData.size(), 0);
	// process in chunk of 256 samples
	int32_t blockSize = 256;
	
	Performance perfo;
	/*
	audio::algo::chunkware::Compressor algo;
	algo.setThreshold(-10);
	algo.setRatio(-5);
	int32_t lastPourcent = -1;
	for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
		if (lastPourcent != 100*iii / (output.size()/blockSize)) {
			lastPourcent = 100*iii / (output.size()/blockSize);
			TEST_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
		} else {
			TEST_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
		}
		perfo.tic();
		algo.process(audio::format_double, &output[iii*blockSize], &inputData[iii*blockSize], blockSize, 1);
		if (perf == true) {
			perfo.toc();
			std::this_thread::sleep_for(std::chrono::milliseconds(1));
		}
	}
	*/
	audio::algo::chunkware::Limiter algo;
	algo.setSampleRate(48000);
	algo.setThreshold(0);
	algo.setAttack(0.1);
	algo.setRelease(2);
	algo.init(1);
	int32_t lastPourcent = -1;
	for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
		if (lastPourcent != 100*iii / (output.size()/blockSize)) {
			lastPourcent = 100*iii / (output.size()/blockSize);
			TEST_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
		} else {
			TEST_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
		}
		perfo.tic();
		algo.process(&output[iii*blockSize], &inputData[iii*blockSize], blockSize, 1, audio::format_double);
		if (perf == true) {
			perfo.toc();
			std::this_thread::sleep_for(std::chrono::milliseconds(1));
		}
	}
	
	
	if (perf == true) {
		TEST_INFO("Performance Result: ");
		TEST_INFO("    blockSize=" << blockSize << " sample");
		TEST_INFO("    min=" << perfo.getMinProcessing().count() << " ns");
		TEST_INFO("    max=" << perfo.getMaxProcessing().count() << " ns");
		TEST_INFO("    avg=" << perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << " ns");
		
		TEST_INFO("    min=" << (float((perfo.getMinProcessing().count()*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
		TEST_INFO("    max=" << (float((perfo.getMaxProcessing().count()*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
		TEST_INFO("    avg=" << (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRate)/blockSize)/1000000000.0)*100.0 << " %");
	}
	etk::FSNodeWriteAllDataType<int16_t>("output.raw", convert(output));
	
}
Beispiel #7
0
void testFSNode() {
	TEST_INFO("==> Start test of FSNode");
	std::string fileName("USERDATA:myFileTest.txt");
	etk::FSNode myNodeTest1(fileName);
	TEST_INFO("********************************************");
	TEST_INFO("** Filename=\"" << fileName << "\"");
	TEST_INFO("********************************************");
	TEST_INFO("      GetNameFolder()      ='" << myNodeTest1.getNameFolder() << "'");
	TEST_INFO("      GetName()            ='" << myNodeTest1.getName() << "'");
	TEST_INFO("      GetNameFile()        ='" << myNodeTest1.getNameFile() << "'");
	TEST_INFO("      GetRelativeFolder()  ='" << myNodeTest1.getRelativeFolder() << "'");
	TEST_INFO("      getFileSystemName()  ='" << myNodeTest1.getFileSystemName() << "'");
	TEST_INFO("      exist                =" << myNodeTest1.exist());
	if (true==myNodeTest1.exist()) {
		TEST_ERROR(" ==> remove the file ==> bad for the test");
	} else {
		TEST_INFO("      Display time when file does not exist :");
		TEST_INFO("          TimeCreatedString()  ='" << myNodeTest1.timeCreatedString() << "'");
		TEST_INFO("          TimeModifiedString() ='" << myNodeTest1.timeModifiedString() << "'");
		TEST_INFO("          TimeAccessedString() ='" << myNodeTest1.timeAccessedString() << "'");
	}
	myNodeTest1.touch();
	if (false==myNodeTest1.exist()) {
		TEST_ERROR(" ==> Error, can not create the file ....");
	} else {
		TEST_INFO("      Display time when file does exist :");
		TEST_INFO("          TimeCreatedString()  ='" << myNodeTest1.timeCreatedString() << "'");
		TEST_INFO("          TimeModifiedString() ='" << myNodeTest1.timeModifiedString() << "'");
		TEST_INFO("          TimeAccessedString() ='" << myNodeTest1.timeAccessedString() << "'");
	}
	etk::FSNode myNodeTest2(fileName);
	TEST_INFO("********************************************");
	TEST_INFO("** Filename2=\"" << myNodeTest2<< "\"");
	TEST_INFO("********************************************");
	TEST_INFO("      GetNameFolder()      ='" << myNodeTest2.getNameFolder() << "'");
	TEST_INFO("      GetName()            ='" << myNodeTest2.getName() << "'");
	TEST_INFO("      GetNameFile()        ='" << myNodeTest2.getNameFile() << "'");
	TEST_INFO("      GetRelativeFolder()  ='" << myNodeTest2.getRelativeFolder() << "'");
	TEST_INFO("      getFileSystemName()  ='" << myNodeTest2.getFileSystemName() << "'");
	TEST_INFO("      exist                =" << myNodeTest2.exist());
	if (false==myNodeTest1.exist()) {
		TEST_ERROR(" ==> Error, can not create the file ....");
	} else {
		TEST_INFO("      Display time when file does exist :");
		TEST_INFO("          TimeCreatedString()  ='" << myNodeTest2.timeCreatedString() << "'");
		TEST_INFO("          TimeModifiedString() ='" << myNodeTest2.timeModifiedString() << "'");
		TEST_INFO("          TimeAccessedString() ='" << myNodeTest2.timeAccessedString() << "'");
	}
	// Try remove the file : 
	myNodeTest1.remove();
	if (true==myNodeTest1.exist()) {
		TEST_ERROR(" ==> The file might be removed ==> but it is not the case ...");
	} else {
		TEST_INFO(" ==> The file is removed");
	}
	TEST_INFO("********************************************");
	TEST_INFO("==> Stop test of FSNode");
}