LONGBOW_TEST_CASE(Global, setGetCapacity)
{
    AthenaLRUContentStoreConfig config;
    config.capacityInMB = 10;
    AthenaContentStore *store = athenaContentStore_Create(&AthenaContentStore_LRUImplementation, &config);

    size_t capacity = athenaContentStore_GetCapacity(store);
    assertTrue(capacity = config.capacityInMB, "Expected the same capacity as we specified at init");

    size_t newCapacity = 20;
    athenaContentStore_SetCapacity(store, newCapacity);

    assertTrue(newCapacity == athenaContentStore_GetCapacity(store), "Expected to see the new capacity");

    athenaContentStore_Release(&store);
}
LONGBOW_TEST_CASE(EmptyImplementation, booleanApiFunctions)
{
    AthenaContentStore *store = athenaContentStore_Create(&EmptyContentStoreImplementation, NULL);

    CCNxContentObject *contentObject = _createContentObject("lci:/dogs/are/better/than/cats", 10, NULL);
    CCNxName *name = ccnxName_CreateFromURI("lci:/pie/is/always/good");
    CCNxInterest *interest = ccnxInterest_CreateSimple(name);

    //athena_EncodeMessage(interest);

    AthenaContentStore *ref = athenaContentStore_Acquire(store);
    athenaContentStore_Release(&ref);

    assertFalse(athenaContentStore_PutContentObject(store, contentObject), "Expected false from PutContentObject");
    assertFalse(athenaContentStore_GetMatch(store, interest), "Expected false from GetMatch");
    assertFalse(athenaContentStore_SetCapacity(store, 1), "Expected false from SetCapacity");
    assertFalse(athenaContentStore_RemoveMatch(store, name, NULL, NULL), "Expected false from RemoveMatch");

    ccnxName_Release(&name);
    ccnxInterest_Release(&interest);
    ccnxContentObject_Release(&contentObject);
    athenaContentStore_Release(&store);
}
Beispiel #3
0
static void
_parseCommandLine(Athena *athena, int argc, char **argv)
{
    int c;
    bool interfaceConfigured = false;

    while ((c = getopt_long(argc, argv, "hs:c:vd", options, NULL)) != -1) {
        switch (c) {
            case 's': {
                int sizeInMB = atoi(optarg);
                if (athenaContentStore_SetCapacity(athena->athenaContentStore, sizeInMB) != true) {
                    parcLog_Error(athena->log, "Unable to resize content store to %d (MB)", sizeInMB);
                }
                _contentStoreSizeInMB = sizeInMB;
                break;
            }
            case 'c': {
                PARCURI *connectionURI = parcURI_Parse(optarg);
                const char *result = athenaTransportLinkAdapter_Open(athena->athenaTransportLinkAdapter, connectionURI);
                if (result == NULL) {
                    parcLog_Error(athena->log, "Unable to configure %s: %s", optarg, strerror(errno));
                    parcURI_Release(&connectionURI);
                    exit(EXIT_FAILURE);
                }
                parcURI_Release(&connectionURI);
                interfaceConfigured = true;
                break;
            }
            case 'v':
                printf("%s\n", athenaAbout_Version());
                exit(0);
            case 'd':
                athenaTransportLinkAdapter_SetLogLevel(athena->athenaTransportLinkAdapter, PARCLogLevel_Debug);
                parcLog_SetLevel(athena->log, PARCLogLevel_Debug);
                break;
            case 'h':
            default:
                _usage();
                exit(EXIT_FAILURE);
                break;
        }
    }

    if (argc - optind) {
        parcLog_Error(athena->log, "Bad arguments");
        _usage();
        exit(EXIT_FAILURE);
    }

    if (interfaceConfigured != true) {
        PARCURI *connectionURI = parcURI_Parse(_athenaDefaultConnectionURI);
        if (athenaTransportLinkAdapter_Open(athena->athenaTransportLinkAdapter, connectionURI) == NULL) {
            parcLog_Error(athena->log, "Unable to configure an interface.  Exiting...");
            parcURI_Release(&connectionURI);
            exit(EXIT_FAILURE);
        }
        parcURI_Release(&connectionURI);
        struct utsname name;
        if (uname(&name) == 0) {
            char nodeURIspecification[MAXPATHLEN];
            sprintf(nodeURIspecification, "tcp://%s:%d/listener",
                    name.nodename, AthenaDefaultListenerPort);
            PARCURI *nodeURI = parcURI_Parse(nodeURIspecification);
            if (athenaTransportLinkAdapter_Open(athena->athenaTransportLinkAdapter, nodeURI) == NULL) {
                parcURI_Release(&nodeURI);
            }
        }
    }
}