/**
 * Unit test framework entry point for this set of unit tests.
 *  
 */
void testSimpleNetwork_runTests() {
    unsigned char ipBytes[MAX_ADDR_LENGTH]; //can be set to INET6_ADDRSTRLEN;
    void *handle;
    int numBytes;
    char *data;
    char *hostname = "host.domain";
    char* request = "GET /midlets/midlet.jad HTTP/1.0\n\n";

    testGetHostByName(hostname, ipBytes);

    handle = testOpen(ipBytes, 80);
    printf("open handle = %d\n", (int)handle);

    testWrite(handle, request);

    numBytes = testAvailable(handle);
    printf("numBytes = %d\n", numBytes);

    if (numBytes > 0) {
        data = (char *) malloc((numBytes + 1)*sizeof(char));
        testRead(handle, data, numBytes);
        printf("\n Data from server :\n");
        printf("%s\n", data);
    }

    testClose(handle);
}
Esempio n. 2
0
/**
 * Main entry point for donuts.
 */
void
testSimpleNetwork_runTests()
{
    puts("===== testSocketOpen =====");
    testSocketOpen();
    puts("===== testSocketOpenFail =====");
    testSocketOpenFail();
    puts("===== testSocketRead =====");
    testSocketRead();
    puts("===== testSocketWrite =====");
    testSocketWrite();
    puts("===== testSocketReadWrite =====");
    testSocketReadWrite();
    puts("===== testGetHostByName =====");
    testGetHostByName();
    puts("===== testAddrToString =====");
    testAddrToString();
    puts("===== testAvailable =====");
    testAvailable();
    puts("===== testSimpleNetwork finished =====");
}