libomemo: add test

pull/1706/head
Boris Pek 7 years ago
parent c78fdfb576
commit bda9cc9b9a

@ -0,0 +1,38 @@
// This file is part of MXE. See LICENSE.md for licensing information.
#include <libomemo.h>
#include <libomemo_crypto.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
char * msg_p = "<message xmlns='jabber:client' type='chat' to='alice@example.com'>"
"<body>hello</body>"
"</message>";
printf("Original message:\n%s\n\n", msg_p);
fflush(stdout);
omemo_crypto_provider crypto = {
.random_bytes_func = omemo_default_crypto_random_bytes,
.aes_gcm_encrypt_func = omemo_default_crypto_aes_gcm_encrypt,
.aes_gcm_decrypt_func = omemo_default_crypto_aes_gcm_decrypt,
(void *) 0
};
uint32_t sid = 9178;
omemo_message * msg_out_p;
if (omemo_message_prepare_encryption(msg_p, sid, &crypto, &msg_out_p) != 0)
return 1;
char * xml_out_p;
if (omemo_message_export_encrypted(msg_out_p, &xml_out_p) != 0)
return 1;
printf("Encrypted message:\n%s\n\n", xml_out_p);
fflush(stdout);
return 0;
}

@ -0,0 +1,22 @@
# This file is part of MXE. See LICENSE.md for licensing information.
# partial module - included by src/cmake/CMakeLists.txt
set(TGT test-${PKG}-cmake)
enable_language(C)
add_executable(${TGT} ${CMAKE_CURRENT_LIST_DIR}/${PKG}-test.c)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB2 glib-2.0)
include_directories(${GLIB2_INCLUDE_DIRS})
target_link_libraries(${TGT} omemo-conversations
mxml
gcrypt
gpg-error
pthread
${GLIB2_LIBRARIES})
install(TARGETS ${TGT} DESTINATION bin)

@ -20,6 +20,13 @@ define $(PKG)_BUILD
$(INSTALL) -m644 '$(1)/build'/libomemo*.a '$(PREFIX)/$(TARGET)/lib/'
$(INSTALL) -d '$(PREFIX)/$(TARGET)/include'
$(INSTALL) -m644 '$(1)/src'/libomemo*.h '$(PREFIX)/$(TARGET)/include/'
# test cmake
mkdir '$(1).test-cmake'
cd '$(1).test-cmake' && '$(TARGET)-cmake' \
-DPKG=$(PKG) \
'$(PWD)/src/cmake/test'
$(MAKE) -C '$(1).test-cmake' -j 1 install
endef
$(PKG)_BUILD_SHARED =

Loading…
Cancel
Save