add simple test
This commit is contained in:
parent
8c12733e19
commit
14031ca668
|
@ -12,6 +12,25 @@ target_link_libraries(
|
||||||
PRIVATE os util common nodes
|
PRIVATE os util common nodes
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_executable(runUdf test/runUdf.c)
|
||||||
|
target_include_directories(
|
||||||
|
runUdf
|
||||||
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/function"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
runUdf
|
||||||
|
PRIVATE os util common nodes function
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(udf1 MODULE test/udf1.c)
|
||||||
|
target_include_directories(
|
||||||
|
udf1
|
||||||
|
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/function"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
|
||||||
|
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
||||||
add_executable(udfd src/udfd.c)
|
add_executable(udfd src/udfd.c)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
udfd
|
udfd
|
||||||
|
@ -22,4 +41,5 @@ target_include_directories(
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
udfd
|
udfd
|
||||||
PRIVATE os util common nodes function
|
PRIVATE os util common nodes function
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "uv.h"
|
||||||
|
#include "tudf.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
startUdfService();
|
||||||
|
uv_sleep(1000);
|
||||||
|
char path[256] = {0};
|
||||||
|
size_t cwdSize = 256;
|
||||||
|
int err = uv_cwd(path, &cwdSize);
|
||||||
|
if (err != 0) {
|
||||||
|
fprintf(stderr, "err cwd: %s\n", uv_strerror(err));
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
fprintf(stdout, "current working directory:%s\n", path);
|
||||||
|
strcat(path, "/libudf1.so");
|
||||||
|
SUdfInfo udfInfo = {.udfName="udf1", .path=path};
|
||||||
|
|
||||||
|
UdfHandle handle;
|
||||||
|
setupUdf(&udfInfo, &handle);
|
||||||
|
|
||||||
|
//char state[5000000] = "state";
|
||||||
|
//char input[5000000] = "input";
|
||||||
|
int dataSize = 500;
|
||||||
|
int callCount = 2;
|
||||||
|
if (argc > 1) dataSize = atoi(argv[1]);
|
||||||
|
if (argc > 2) callCount = atoi(argv[2]);
|
||||||
|
char *state = malloc(dataSize);
|
||||||
|
char *input = malloc(dataSize);
|
||||||
|
SUdfDataBlock blockInput = {.data = input, .size = dataSize};
|
||||||
|
SUdfDataBlock blockOutput;
|
||||||
|
char* newState;
|
||||||
|
int32_t newStateSize;
|
||||||
|
for (int l = 0; l < callCount; ++l) {
|
||||||
|
callUdf(handle, 0, state, dataSize, blockInput, &newState, &newStateSize, &blockOutput);
|
||||||
|
}
|
||||||
|
free(state);
|
||||||
|
free(input);
|
||||||
|
teardownUdf(handle);
|
||||||
|
|
||||||
|
stopUdfService();
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "tudf.h"
|
||||||
|
|
||||||
|
void udf1(int8_t step, char *state, int32_t stateSize, SUdfDataBlock input,
|
||||||
|
char **newState, int32_t *newStateSize, SUdfDataBlock *output) {
|
||||||
|
fprintf(stdout, "%s, step:%d\n", "udf function called", step);
|
||||||
|
char *newStateBuf = malloc(stateSize);
|
||||||
|
memcpy(newStateBuf, state, stateSize);
|
||||||
|
*newState = newStateBuf;
|
||||||
|
*newStateSize = stateSize;
|
||||||
|
|
||||||
|
char *outputBuf = malloc(input.size);
|
||||||
|
memcpy(outputBuf, input.data, input.size);
|
||||||
|
output->data = outputBuf;
|
||||||
|
output->size = input.size;
|
||||||
|
return;
|
||||||
|
}
|
Loading…
Reference in New Issue