Commit ae1fe754 authored by Greg Williams's avatar Greg Williams
Browse files

Updated DELETE tests to specify only tag and dbVersion, since other key/value...

Updated DELETE tests to specify only tag and dbVersion, since other key/value fields are unnecessary.
Added versioned .so to make install. Make uninstall will removed ALL versions of libkinetic-c-client.*.so for now. Symlinks will have to be added for default, major and minor versions for scoped linkage.
parent b64926d2
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -12,8 +12,11 @@ PBC_INC = ./vendor/protobuf-c
SOCKET99 = ./vendor/socket99
VND_INC = ./vendor
BIN = $(BIN_DIR)/kinetic_client
LDFLAGS += -lm -l crypto -l ssl

KINETIC_LIB = $(BIN_DIR)/lib${PROJECT}.a
VERSION = `head -n1 VERSION`
KINETIC_SO = $(BIN_DIR)/lib${PROJECT}.${VERSION}.so
UTIL_EXEC = $(BIN_DIR)/$(PROJECT)-util

CC = gcc
@@ -22,14 +25,14 @@ WARN = -Wall -Wextra -pedantic
# This is necessary because the library depends on
# both C99 _and_ POSIX (for the BSD sockets API).
CDEFS += -D_POSIX_C_SOURCE=1
CFLAGS += -std=c99 -g ${WARN} ${CDEFS} ${OPTIMIZE}
CFLAGS += -std=c99 -fPIC -g ${WARN} ${CDEFS} ${OPTIMIZE}

LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PBC_INC) -I$(VND_INC)
LIB_DEPS = $(PUB_INC)/kinetic_client.h $(PUB_INC)/kinetic_types.h $(LIB_DIR)/kinetic_connection.h $(LIB_DIR)/kinetic_hmac.h $(LIB_DIR)/kinetic_logger.h $(LIB_DIR)/kinetic_message.h $(LIB_DIR)/kinetic_nbo.h $(LIB_DIR)/kinetic_operation.h $(LIB_DIR)/kinetic_pdu.h $(LIB_DIR)/kinetic_proto.h $(LIB_DIR)/kinetic_socket.h
# LIB_OBJ = $(patsubst %,$(OUT_DIR)/%,$(LIB_OBJS))
LIB_OBJS = $(OUT_DIR)/kinetic_nbo.o $(OUT_DIR)/kinetic_operation.o $(OUT_DIR)/kinetic_pdu.o $(OUT_DIR)/kinetic_proto.o $(OUT_DIR)/kinetic_socket.o $(OUT_DIR)/kinetic_message.o $(OUT_DIR)/kinetic_message.o $(OUT_DIR)/kinetic_logger.o $(OUT_DIR)/kinetic_hmac.o $(OUT_DIR)/kinetic_connection.o $(OUT_DIR)/kinetic_operation.o $(OUT_DIR)/kinetic_types.o $(OUT_DIR)/kinetic_client.o $(OUT_DIR)/socket99.o $(OUT_DIR)/protobuf-c.o
LIB_OBJS = $(OUT_DIR)/kinetic_nbo.o $(OUT_DIR)/kinetic_operation.o $(OUT_DIR)/kinetic_pdu.o $(OUT_DIR)/kinetic_proto.o $(OUT_DIR)/kinetic_socket.o $(OUT_DIR)/kinetic_message.o $(OUT_DIR)/kinetic_logger.o $(OUT_DIR)/kinetic_hmac.o $(OUT_DIR)/kinetic_connection.o $(OUT_DIR)/kinetic_types.o $(OUT_DIR)/kinetic_client.o $(OUT_DIR)/socket99.o $(OUT_DIR)/protobuf-c.o

default: $(KINETIC_LIB)
default: $(KINETIC_SO)

test: Rakefile $(LIB_OBJS)
	bundle install
@@ -72,10 +75,14 @@ $(KINETIC_LIB): $(LIB_OBJS)
	ar -rcs $@ $(LIB_OBJS)
	ar -t $@

$(KINETIC_SO): $(KINETIC_LIB)
	$(CC) $(LIB_OBJS) -shared ${LDFLAGS} -o ${KINETIC_SO}

libso: $(KINETIC_SO)

UTIL_OBJS = $(OUT_DIR)/noop.o $(OUT_DIR)/put.o $(OUT_DIR)/get.o $(OUT_DIR)/delete.o
UTIL_INCS = -I/usr/local/include -I$(UTIL_DIR)
# TODO: Delete LIB_DIR dep after kinetic_proto is yanked out of public API
LDFLAGS += -lm -l kinetic-c-client -l crypto -l ssl

$(OUT_DIR)/noop.o: $(UTIL_EX)/noop.c
	$(CC) -c -o $@ $< $(CFLAGS) $(UTIL_INCS)
@@ -86,7 +93,7 @@ $(OUT_DIR)/get.o: $(UTIL_EX)/get.c
$(OUT_DIR)/delete.o: $(UTIL_EX)/delete.c
	$(CC) -c -o $@ $< $(CFLAGS) $(UTIL_INCS)
$(UTIL_EXEC): $(UTIL_DIR)/main.c $(UTIL_OBJS)
	${CC} -o $@ $< $(UTIL_OBJS) $(UTIL_INCS) ${CFLAGS} ${LDFLAGS}
	${CC} -o $@ $< $(UTIL_OBJS) $(UTIL_INCS) ${CFLAGS}  -l kinetic-c-client ${LDFLAGS}

utility: ${UTIL_EXEC}

@@ -118,9 +125,10 @@ PREFIX ?= /usr/local
INSTALL ?= install
RM ?= rm

install: ${KINETIC_LIB}
install: ${KINETIC_LIB} ${KINETIC_SO} VERSION
	${INSTALL} -d ${PREFIX}/lib/
	${INSTALL} -c ${KINETIC_LIB} ${PREFIX}/lib/
	${INSTALL} -c ${KINETIC_SO} ${PREFIX}/lib/
	${INSTALL} -d ${PREFIX}/include/
	${INSTALL} -c ./include/${LIB_NAME}.h ${PREFIX}/include/
	${INSTALL} -c ./include/kinetic_types.h ${PREFIX}/include/
@@ -129,7 +137,8 @@ install: ${KINETIC_LIB}
	${INSTALL} -c ./vendor/protobuf-c/protobuf-c/protobuf-c.h ${PREFIX}/include/protobuf-c/

uninstall:
	${RM} -f ${PREFIX}/lib/lib${PROJECT}.a
	${RM} -f ${PREFIX}/lib/lib${PROJECT}*.a
	${RM} -f ${PREFIX}/lib/lib${PROJECT}*.so
	${RM} -f ${PREFIX}/include/${LIB_NAME}.h
	${RM} -f ${PREFIX}/include/kinetic_types.h
	${RM} -f ${PREFIX}/include/kinetic_proto.h
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ void test_Delete_should_delete_an_object_from_the_device(void)
    ByteArray valueKey = BYTE_ARRAY_INIT_FROM_CSTRING("my_key_3.1415927");
    KineticKeyValue metadata = {
        .key = valueKey,
        .dbVersion = BYTE_ARRAY_INIT_FROM_CSTRING("v4.2.3"),
    };

    // Initialize response message status and HMAC
+11 −5
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ void tearDown(void)
//
void test_Delete_should_delete_an_object_from_device(void)
{
    KineticKeyValue metadata = {
    KineticKeyValue getMetadata = {
        .key = ValueKey, 
        .tag = Tag,
        .dbVersion = Version,
@@ -105,14 +105,20 @@ void test_Delete_should_delete_an_object_from_device(void)
        &Fixture.connection, &Fixture.request, &Fixture.response);
    KINETIC_PDU_INIT_WITH_MESSAGE(&Fixture.request, &Fixture.connection);
    KINETIC_PDU_INIT(&Fixture.response, &Fixture.connection);
    status = KineticClient_Get(&Fixture.instance.operation, &metadata);
    status = KineticClient_Get(&Fixture.instance.operation, &getMetadata);
    TEST_ASSERT_EQUAL_KINETIC_STATUS(KINETIC_STATUS_SUCCESS, status);
    TEST_ASSERT_EQUAL_ByteArray(TestValue, metadata.value);
    TEST_ASSERT_EQUAL_ByteArray(TestValue, getMetadata.value);
    Fixture.expectedSequence++;
    TEST_ASSERT_EQUAL_MESSAGE(Fixture.expectedSequence, Fixture.connection.sequence,
        "Sequence should post-increment for every operation on the session!");

    // Delete the object
    KineticKeyValue metadata = {
        .key = ValueKey, 
        .dbVersion = Version,
    };
    metadata.algorithm = (KineticProto_Algorithm)0;
    metadata.tag = BYTE_ARRAY_NONE;
    Fixture.instance.operation = KineticClient_CreateOperation(
        &Fixture.connection, &Fixture.request, &Fixture.response);
    KINETIC_PDU_INIT_WITH_MESSAGE(&Fixture.request, &Fixture.connection);
@@ -129,9 +135,9 @@ void test_Delete_should_delete_an_object_from_device(void)
        &Fixture.connection, &Fixture.request, &Fixture.response);
    KINETIC_PDU_INIT_WITH_MESSAGE(&Fixture.request, &Fixture.connection);
    KINETIC_PDU_INIT(&Fixture.response, &Fixture.connection);
    status = KineticClient_Get(&Fixture.instance.operation, &metadata);
    status = KineticClient_Get(&Fixture.instance.operation, &getMetadata);
    TEST_ASSERT_EQUAL_KINETIC_STATUS(KINETIC_STATUS_DATA_ERROR, status);
    TEST_ASSERT_EQUAL(0, metadata.value.len);
    TEST_ASSERT_EQUAL(0, getMetadata.value.len);
}

/*******************************************************************************
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ void test_KineticClient_Delete_should_execute_DELETE_operation(void)
    ByteArray hmacKey = BYTE_ARRAY_INIT_FROM_CSTRING("some_hmac_key");
    KineticKeyValue metadata = {
        .key = BYTE_ARRAY_INIT_FROM_CSTRING("my_key_3.1415927"),
        .dbVersion = BYTE_ARRAY_INIT_FROM_CSTRING("v2.3")
    };
    KINETIC_PDU_INIT(&Request, &connection);
    Response.protoData.message.proto.command = &responseCommand;