Beispiel #1
0
/*
 * Realizes the queue ADT with an Array and then a LinkedList
 */
int main(void) {
    Queue queue;

    printf("Array Queue Tests\n");
    newArrayQueue(&queue);
    testQueue(&queue);
    deleteArrayQueue(&queue);

    printf("\n");
    printf("Linked Queue Tests\n");
    newLinkedQueue(&queue);
    testQueue(&queue);
    deleteLinkedQueue(&queue);
    return 0;
}
Beispiel #2
0
void test(){
	 testQueue(50000);
	 test_serialization(500);
	 testRule(50000);
	 testTree(5000);
	 testqbm(5000);

}
Beispiel #3
0
void testDataStructures() {
    testFileCache();
    testBitMap();
    testQueue();
    testPriorityQueue();
    testHashMap();

    cout << "Datastructures test Done" << endl;
}
void ContainerUnitTest::execute() {
	std::cout << "Stack<long>" << std::endl;
	Stack<long> stack1;
	testStack(&stack1);

	std::cout << "Stack<char*>" << std::endl;
	Stack<char*> stack2;
	testStack(&stack2);

	std::cout << "Queue<long>" << std::endl;
	Queue<long> queue1;
	testQueue(&queue1);

	std::cout << "Queue<char*>" << std::endl;
	Queue<long> queue2;
	testQueue(&queue2);

}
Beispiel #5
0
void main()
{
	CircleQueue<Ts> testQueue(2);

	for (int idx = 0; idx < 1000 ; idx++)
	{
		Ts ts;
		ts.i = 1;
		ts.j = 2;
		testQueue.PushFront(ts);

		Ts ts2;
		ts2.i = 11;
		ts2.j = 22;
		testQueue.PushBack(ts2);
	}

}
void testDataStructures() {
    testFileCache();
    testBitMap();
    testQueue();
    testPriorityQueue();
    testHashMap();

    ConcurrentLinkedList<int> cll;
    ConcurrentLinkedList<CharString> cll2;
    ConcurrentLinkedList<CharString*> cll3;
    ConcurrentLinkedList<CharString**> cll4;
    CharString** p = (CharString**)malloc(sizeof(CharString));
    p[0] = new CharString("blah");
    cll.add(1);
    cll2.add(CharString("blah"));
    cll3.add(new CharString("blah"));
    cll4.add(p);

    cout << "Datastructures test Done" << endl;
}
Beispiel #7
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    bool flgExit = false;

    for ( ; !flgExit ; )
    {
        std::cout << "\nS -test Single List"
                  << "\nD -test Double List"
                  << "\nQ -test Queue"
                  << "\nE - Exit ==>" ;

        std::string cmd;
        getCmd (cmd);
        if (cmd.size () == 0)
        {
            continue;
        }


        char c1 = toupper (cmd[0]);
        switch ( c1 )
        {
        case 'S' :
            testSingleList ();
            break;
        case 'Q' :
            testQueue ();
            break;
        case 'D' :
            testDoubleList ();
            break;
        case 'E' : 
            flgExit = true;
            break;
        }
    }

    return 0;
}
Beispiel #8
0
VOID
TestDequeCode(
    PVMDIR_TEST_STATE pState
    )
{
    DWORD dwError = 0;
    PDEQUE pDeque = NULL;

    printf("Testing deque code ...");

    dwError = dequeCreate(&pDeque);
    TestAssertEquals(dwError, ERROR_SUCCESS);

    testEmpty(pState, pDeque);
    testQueue(pState, pDeque);
    testStack(pState, pDeque);
    testEmpty(pState, pDeque);

    dequeFree(pDeque);

    printf(" PASSED\n");
}
int main(int argc, const char** argv)
{
    try
    {
        testQueue();

        constexpr unsigned VirtualIfacePoolSize = 32768;

        if (argc < 3)
        {
            std::cerr << "Usage:\n\t" << argv[0] << " <node-id> <can-iface-name-1> [can-iface-name-N...]" << std::endl;
            return 1;
        }

        const int self_node_id = std::stoi(argv[1]);
        std::vector<std::string> iface_names(argv + 2, argv + argc);

        auto node = initMainNode(iface_names, self_node_id, "org.uavcan.linux_test_node");
        auto sub_node = initSubNode<VirtualIfacePoolSize>(iface_names.size(), *node);

        std::thread sub_thread([&sub_node](){ runSubNode(sub_node); });

        runMainNode(node);

        if (sub_thread.joinable())
        {
            std::cout << "Waiting for the sub thread to join" << std::endl;
            sub_thread.join();
        }

        return 0;
    }
    catch (const std::exception& ex)
    {
        std::cerr << "Exception: " << ex.what() << std::endl;
        return 1;
    }
}
Beispiel #10
0
int _tmain(int argc, _TCHAR* argv[])
{
	classLibInit();
	memPartLibInit(memBuf, MEM_LEN);

	char* a1 = (char*)memPartAlloc(memSysPartId, 10);
	char* a2 = (char*)memPartAlloc(memSysPartId, 45);
	memPartFree(memSysPartId, a1);
	memPartFree(memSysPartId, a2);

	a1 = (char*)memPartAlloc(memSysPartId, 10);
	a2 = (char*)memPartAlloc(memSysPartId, 45);

	memPartFree(memSysPartId, a2);
	memPartFree(memSysPartId, a1);

	a1 = (char*)memPartAlloc(memSysPartId, 10);
	a2 = (char*)memPartAlloc(memSysPartId, 12);
	char* a3 = (char*)memPartAlloc(memSysPartId, 45);

	memPartFree(memSysPartId, a2);

	char* a4 = (char*)memPartAlloc(memSysPartId, 12);

	testQueue();

	SEM_ID semId = semMCreate(0);

	int c = 0;
	semTake(semId, WAIT_FOREVER);
	c++;
	semGive(semId);

	semDelete(semId);

	gets(a1);
	return 0;
}
Beispiel #11
0
TEST(FuturesTestSuite, testJobQueue8)
{
    testQueue(8);
}
Beispiel #12
0
TEST(FuturesTestSuite, testJobQueue2)
{
    testQueue(2);
}
Beispiel #13
0
TEST(FuturesTestSuite, testJobQueue1)
{
    testQueue(1);
}
Beispiel #14
0
int main(int argc, char* const argv[]) {
    if (testQueue() != 0) {
        exit(-1);
    }
    // Check for flags
    int nrOfCryptThreads = 0;
    nrOfReadThreads = 0;
    int nrOfBuffers = 0;
    int ch;
    const char *optstring = "C:P:B:";
    while((ch = getopt(argc, argv, optstring)) != -1) {
        switch (ch) {
        case 'P': /* Number of read-threads */
            nrOfReadThreads = atoi(optarg);
            break;
        case 'C': /* Number of computers (crypt-threads) */
            nrOfCryptThreads = atoi(optarg);
            break;
        case 'B': /* Number of buffers */
            nrOfBuffers = atoi(optarg);
            break;
        case '?':
        default:
            usage();
            exit(1);
        }
    }
    argc -= optind;
    argv += optind;

    if (nrOfBuffers < 1 || nrOfCryptThreads < 1 || nrOfReadThreads < 1) {
        printf("nrOfBuffers: %d\n", nrOfBuffers);
        printf("nrOfCryptThreads: %d\n", nrOfCryptThreads);
        printf("nrOfReadThreads: %d\n", nrOfReadThreads);
        usage();
        exit(1);
    }

    /* Init Queues to hold Buffers with log messages */
    //extern Queue *freeBufQueue;
    createQueue(&freeBufQueue, nrOfBuffers);
    //extern Queue *filledBufQueue;
    createQueue(&filledBufQueue, nrOfBuffers);

    printf("filledbufqueue: ");
    printQueue(&filledBufQueue);
    int i;
    for (i = 0; i < nrOfBuffers; i++) {
        LogBuf *b;
        b = malloc(sizeof(LogBuf));
        b->fifo = -1;
        b->message = malloc(LOG_MSG_SIZE);
        enqueue(&freeBufQueue, b);
        printf("enqueueing%d\n", i);
    }

    printf("freeBufQueue: ");
    printQueue(&freeBufQueue);

    /* Read key from file `keys' */
    readKey(key, MAXKEYSIZE);
    printf("key: %s\n", key);

    /* Init fifo_count and fifo_mutex */
    fifo_count = malloc(nrOfReadThreads * sizeof(int));
    for (i = 0; i < nrOfReadThreads; i++) {
        fifo_count[i] = 0;
    }
    if (pthread_mutex_init(&fifo_mutex, NULL) != 0) {
        fprintf(stderr, "Couldn't init fifo_mutex\n");
        exit(1);
    }

    /* Start read threads */
    pthread_t readThreadArray[nrOfReadThreads];
    for (i = 0; i < nrOfReadThreads; i++) {
        if (pthread_create(&readThreadArray[i], NULL, readThreadInit,
                           (void*) i) != 0) {
            fprintf(stderr, "Failed to create thread.\n");
        }
    }

    /* Start crypt threads */
    pthread_t cryptThreadArray[nrOfCryptThreads];
    for (i = 0; i < nrOfCryptThreads; i++) {
        if (pthread_create(&cryptThreadArray[i], NULL, cryptThreadInit,
                           (void*) i) != 0) {
            fprintf(stderr, "Failed to create thread.\n");
        }
    }

    // Wait for read threads
    for (i = 0; i < nrOfReadThreads; i++) {
        pthread_join(readThreadArray[i], NULL);
    }

    // Wait for crypt threads
    for (i = 0; i < nrOfCryptThreads; i++) {
        pthread_join(cryptThreadArray[i], NULL);
    }

    /* TODO: Cleanup free stuff */
    return 0;
}