Esempio n. 1
0
static void test_multipleHubsFound(void)
{
    List *list = NULL;

    hostcount = 2;

    assert_int_equal(ListHubs(&list), 3);
    assert_int_not_equal(list, NULL);
    
    ListIterator *i = NULL;
    i = ListIteratorGet(list);
    
    HostProperties *host1 = (HostProperties *)ListIteratorData(i); 
    assert_int_not_equal(ListIteratorNext(i), -1);
    HostProperties *host2 = (HostProperties *)ListIteratorData(i); 
    assert_int_not_equal(ListIteratorNext(i), -1);
    HostProperties *host3 = (HostProperties *)ListIteratorData(i); 

    assert_int_equal(host1->Port, 5308);
    assert_string_equal(host1->Hostname, "host1");
    assert_string_equal(host1->IPAddress, "10.0.0.100");

    assert_int_equal(host2->Port, 1234);
    assert_string_equal(host2->Hostname, "host2");
    assert_string_equal(host2->IPAddress, "10.0.0.100");

    assert_int_equal(host3->Port, 4321);
    assert_string_equal(host3->Hostname, "host3");
    assert_string_equal(host3->IPAddress, "10.0.0.100");

    ListIteratorDestroy(&i);
    ListDestroy(&list);
}
Esempio n. 2
0
void PrintList(List *list)
{
    ListIterator *i = NULL;

    i = ListIteratorGet(list);
    if (!i)
    {
        ProgrammingError("Unable to get iterator for hub list");
        return;
    }

    do
    {
        HostProperties *hostprop = (HostProperties *)ListIteratorData(i);

        CfOut(OUTPUT_LEVEL_REPORTING, "", "\nCFEngine Policy Server:\n"
                                "Hostname: %s\n"
                                "IP Address: %s\n"
                                "Port: %d\n",
                                hostprop->Hostname,
                                hostprop->IPAddress,
                                hostprop->Port);
    } while (ListIteratorNext(i) != -1);

    ListIteratorDestroy(&i);
}
Esempio n. 3
0
void PrintList(List *list)
{
    ListIterator *i = NULL;

    i = ListIteratorGet(list);
    if (!i)
    {
        ProgrammingError("Unable to get iterator for hub list");
        return;
    }

    do
    {
        HostProperties *hostprop = (HostProperties *)ListIteratorData(i);

        Log(LOG_LEVEL_NOTICE, "CFEngine Policy Server: hostname '%s', IP address '%s', port %d",
            hostprop->Hostname, hostprop->IPAddress, hostprop->Port);
    } while (ListIteratorNext(i) != -1);

    ListIteratorDestroy(&i);
}
Esempio n. 4
0
static void test_oneHubFound(void)
{
    List *list = NULL;

    hostcount = 1;

    assert_int_equal(ListHubs(&list), 1);
    assert_int_not_equal(list, NULL);
    
    ListIterator *i = NULL;
    i = ListIteratorGet(list);
    assert_true(i != NULL);
    HostProperties *host = (HostProperties *)ListIteratorData(i);
    
    assert_int_equal(host->Port,5308);
    assert_string_equal(host->Hostname, "host1");
    assert_string_equal(host->IPAddress, "10.0.0.100");

    ListIteratorDestroy(&i);
    ListDestroy(&list);
}