Пример #1
0
void run_tests(TestState *parent, int selectedTest)
{
    TestState state;

    initState(&state, "Test", parent);
    state.selectedTest = selectedTest;

    if (startTest(&state, "the empty command")) {
        if (serialRequest(&state, ""))
            checkSerialResponse(&state, "=S,0");
    }

    if (startTest(&state, "an invalid command")) {
        if (serialRequest(&state, "FOO"))
            checkSerialResponse(&state, "=E,1");
    }

#ifdef DO_BLINK_TEST
    if (startTest(&state, "Blink LEDs on GPIO13 and GPIO15")) {
        if (test_blink(&state))
            passTest(&state, "");
        else
            failTest(&state, "");
    }
#endif

    if (state.ssid) {
        if (startTest(&state, "switch to STA+AP mode")) {
            if (serialRequest(&state, "SET:wifi-mode,3"))
                checkSerialResponse(&state, "=S,0");
        }
        if (startTest(&state, "JOIN")) {
            if (serialRequest(&state, "JOIN:%s,%s", state.ssid, state.passwd))
                checkSerialResponse(&state, "=S,0");
            if (state.testPassed)
                msleep(10000); // wait for WX to disconnect. It has a .5 second delay
        }
        beginGroup(&state);
        if (startTest(&state, "CHECK:station-ipaddr")) {
            if (!skipTest(&state)) {
                char ipaddr[32];
                do {
                    if (!serialRequest(&state, "CHECK:station-ipaddr"))
                        break;
                } while (!waitAndCheckSerialResponse(&state, "=S,0.0.0.0", "=S,^s", ipaddr, sizeof(ipaddr)));
                if (state.testPassed) {
                    infoTest(&state, "got '%s'", ipaddr);
                    if (GetInternetAddress(ipaddr, 80, &state.moduleAddr) != 0)
                        infoTest(&state, "error: failed to parse IP address '%s'", ipaddr);
                }
            }
        }
    }

    if (startTest(&state, "simple transaction")) {
        if (test_001(&state))
            passTest(&state, "");
        else
            failTest(&state, "");
    }

    testResults(&state);
}
Пример #2
0
Файл: refs.c Проект: AndyA/rfile
void test_main() {
  test_001();
}