mirror of
https://github.com/openharmony/third_party_fsverity-utils.git
synced 2026-07-01 10:05:35 -04:00
Make libfsverity.h usable from C++
Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
#ifndef LIBFSVERITY_H
|
||||
#define LIBFSVERITY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@@ -131,4 +135,8 @@ const char *libfsverity_get_hash_name(uint32_t alg_num);
|
||||
*/
|
||||
void libfsverity_set_error_callback(void (*cb)(const char *msg));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBFSVERITY_H */
|
||||
|
||||
@@ -53,6 +53,20 @@ if nm libfsverity.so | grep ' T ' | grep -v " libfsverity_"; then
|
||||
fail "Some exported symbols are not prefixed with \"libfsverity_\""
|
||||
fi
|
||||
|
||||
log "Test using libfsverity from C++ program"
|
||||
cat > /tmp/libfsverity_test.cc <<EOF
|
||||
#include <libfsverity.h>
|
||||
#include <iostream>
|
||||
int main()
|
||||
{
|
||||
std::cout << libfsverity_get_digest_size(FS_VERITY_HASH_ALG_SHA256) << std::endl;
|
||||
}
|
||||
EOF
|
||||
c++ -Wall -Werror /tmp/libfsverity_test.cc -Icommon -L. -lfsverity \
|
||||
-o /tmp/libfsverity_test
|
||||
[ "$(LD_LIBRARY_PATH=. /tmp/libfsverity_test)" = "32" ]
|
||||
rm /tmp/libfsverity_test*
|
||||
|
||||
log "Build and test with gcc"
|
||||
$MAKE CC=gcc check
|
||||
|
||||
@@ -106,3 +120,5 @@ $MAKE CC=gcc CFLAGS="-fanalyzer -Werror" all test_programs
|
||||
|
||||
log "Run shellcheck"
|
||||
shellcheck scripts/*.sh 1>&2
|
||||
|
||||
log "All tests passed!"
|
||||
|
||||
Reference in New Issue
Block a user