test program uses open_memstream for backing

ffi
Avril 3 years ago
parent 57541f233b
commit ba5f979a49
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -44,11 +44,14 @@ FILE* wrap_file(const char* filename, enum cc20_mode mode, cc20_meta_t* restrict
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
((void)argc); ((void)argc);
if(!argv[1]) return 1; ((void)argv);
//if(!argv[1]) return 1;
cc20_meta_t meta; cc20_meta_t meta;
unsigned char* mems = NULL;
size_t mems_sz =0;
FILE* output = wrap_file(argv[1], CC20_ENCRYPT, &meta); FILE* output = wrap_stream(open_memstream((char**)&mems, &mems_sz), CC20_ENCRYPT, NULL, NULL, &meta);//wrap_file(argv[1], CC20_ENCRYPT, &meta);
size_t wsz; size_t wsz;
printf("written %lu bytes\n", (wsz=fwrite(write_string, 1, strlen(write_string), output))); printf("written %lu bytes\n", (wsz=fwrite(write_string, 1, strlen(write_string), output)));
@ -76,6 +79,8 @@ int main(int argc, char** argv)
printf("written %lu bytes\n", wsz); printf("written %lu bytes\n", wsz);
fclose(input); fclose(input);
printf("\nbacking buffer contains: %lu bytes\n", mems_sz);
if(mems) free(mems);
return 0; return 0;
} }

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
gcc test.c -Iinclude -Wall --std=gnu11 -pedantic -Wextra -Og -g -o test-ffi -l:target/debug/libchacha20stream.a -lssl -lcrypto -lpthread -ldl || exit gcc test.c -Iinclude -Wall --std=gnu11 -pedantic -Wextra -Og -g -o test-ffi -l:target/debug/libchacha20stream.a -lssl -lcrypto -lpthread -ldl || exit
valgrind ./test-ffi test-ffi-output valgrind ./test-ffi # test-ffi-output
hexview test-ffi-output #hexview test-ffi-output
rm -f test-ffi{,-output} rm -f test-ffi{,-output}

Loading…
Cancel
Save