Skip to content

Commit

Permalink
Add tests for p11-kit profile commands
Browse files Browse the repository at this point in the history
Signed-off-by: Zoltan Fridrich <[email protected]>
  • Loading branch information
ZoltanFridrich committed Sep 25, 2023
1 parent 2841304 commit 673b7bb
Show file tree
Hide file tree
Showing 11 changed files with 608 additions and 68 deletions.
98 changes: 49 additions & 49 deletions common/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
install_headers('pkcs11.h', 'pkcs11x.h', subdir: 'p11-kit-1/p11-kit')

libp11_asn1_deps = []

if with_asn1
libp11_asn1_sources = [
'asn1.c',
'oid.c',
]

basic_asn_h = custom_target(
'basic.asn.h',
output: 'basic.asn.h',
input: 'basic.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

pkix_asn_h = custom_target(
'pkix.asn.h',
output: 'pkix.asn.h',
input: 'pkix.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

openssl_asn_h = custom_target(
'openssl.asn.h',
output: 'openssl.asn.h',
input: 'openssl.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

asn_h_dep = declare_dependency(
sources: [basic_asn_h, pkix_asn_h, openssl_asn_h],
)

libp11_asn1 = static_library(
'p11-asn1', libp11_asn1_sources,
gnu_symbol_visibility: 'hidden',
include_directories: configinc,
)

libp11_asn1_dep = declare_dependency(
include_directories: [configinc, commoninc],
link_with: libp11_asn1,
dependencies: [asn_h_dep] + libtasn1_deps,
)

libp11_asn1_deps += libp11_asn1_dep
endif

libp11_common_sources = [
'argv.c',
'attrs.c',
Expand Down Expand Up @@ -35,7 +83,7 @@ libp11_library = static_library('p11-library', 'library.c',
include_directories: configinc)

libp11_library_dep = declare_dependency(link_with: libp11_library,
dependencies: [libp11_common_dep] + thread_deps + libintl_deps)
dependencies: [libp11_common_dep] + libp11_asn1_deps + thread_deps + libintl_deps)

libp11_library_whole_dep = declare_dependency(link_whole: libp11_library,
dependencies: [libp11_common_dep] + thread_deps + libintl_deps)
Expand Down Expand Up @@ -66,54 +114,6 @@ libp11_tool = static_library('p11-tool', libp11_tool_sources,
libp11_tool_dep = declare_dependency(link_with: libp11_tool,
dependencies: [libp11_common_dep])

libp11_asn1_deps = []

if with_asn1
libp11_asn1_sources = [
'asn1.c',
'oid.c',
]

basic_asn_h = custom_target(
'basic.asn.h',
output: 'basic.asn.h',
input: 'basic.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

pkix_asn_h = custom_target(
'pkix.asn.h',
output: 'pkix.asn.h',
input: 'pkix.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

openssl_asn_h = custom_target(
'openssl.asn.h',
output: 'openssl.asn.h',
input: 'openssl.asn',
command: [asn1Parser, '-o', '@OUTPUT@', '@INPUT@'],
)

asn_h_dep = declare_dependency(
sources: [basic_asn_h, pkix_asn_h, openssl_asn_h],
)

libp11_asn1 = static_library(
'p11-asn1', libp11_asn1_sources,
gnu_symbol_visibility: 'hidden',
include_directories: configinc,
)

libp11_asn1_dep = declare_dependency(
include_directories: [configinc, commoninc],
link_with: libp11_asn1,
dependencies: [asn_h_dep] + libtasn1_deps,
)

libp11_asn1_deps += libp11_asn1_dep
endif

# Tests ----------------------------------------------------------------

if get_option('test')
Expand Down
3 changes: 3 additions & 0 deletions common/persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ format_constant (CK_ATTRIBUTE *attr,
case CKA_MECHANISM_TYPE:
table = p11_constant_mechanisms;
break;
case CKA_PROFILE_ID:
table = p11_constant_profiles;
break;
default:
table = NULL;
};
Expand Down
File renamed without changes.
7 changes: 6 additions & 1 deletion p11-kit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ check_LTLIBRARIES += \
mock-eight.la \
mock-nine.la \
mock-ten.la \
mock-eleven.la
mock-eleven.la \
mock-thirteen.la

mock_one_la_SOURCES = p11-kit/mock-module-ep.c
mock_one_la_LIBADD = libp11-test.la libp11-common.la
Expand Down Expand Up @@ -587,6 +588,10 @@ mock_eleven_la_SOURCES = p11-kit/mock-module-ep9.c
mock_eleven_la_LDFLAGS = $(mock_one_la_LDFLAGS)
mock_eleven_la_LIBADD = $(mock_one_la_LIBADD)

mock_thirteen_la_SOURCES = p11-kit/mock-module-ep11.c
mock_thirteen_la_LDFLAGS = $(mock_one_la_LDFLAGS)
mock_thirteen_la_LIBADD = $(mock_one_la_LIBADD)

EXTRA_DIST += \
p11-kit/fixtures \
p11-kit/templates \
Expand Down
4 changes: 4 additions & 0 deletions p11-kit/fixtures/package-modules/thirteen.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

module: mock-thirteen.so
managed: yes
enable-in: p11-kit-testable
15 changes: 11 additions & 4 deletions p11-kit/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ p11_kit_sources = [
executable('p11-kit',
p11_kit_sources,
c_args: common_c_args + libp11_kit_internal_c_args,
dependencies: [libp11_tool_dep] + libffi_deps + dlopen_deps,
dependencies: [libp11_tool_dep] + libp11_asn1_deps + libffi_deps + dlopen_deps,
link_with: [libp11_kit, libp11_kit_internal],
install: true)

Expand All @@ -235,7 +235,7 @@ if get_option('test')
c_args: common_c_args + libp11_kit_internal_c_args + [
'-DP11_KIT_TESTABLE'
],
dependencies: [libp11_tool_dep] + libffi_deps + dlopen_deps,
dependencies: [libp11_tool_dep] + libp11_asn1_deps + libffi_deps + dlopen_deps,
link_whole: libp11_kit_testable)
endif

Expand Down Expand Up @@ -403,6 +403,12 @@ if get_option('test')
env: p11_kit_tests_env)
endif

if with_asn1 and host_system != 'windows'
test('test-profiles.sh',
find_program('test-profiles.sh'),
env: p11_kit_tests_env)
endif

mock_sources = {
'mock-one': ['mock-module-ep.c'],
'mock-v3-one': ['mock-module-v3-ep.c'],
Expand All @@ -416,7 +422,8 @@ if get_option('test')
'mock-eight': ['mock-module-ep6.c'],
'mock-nine': ['mock-module-ep7.c'],
'mock-ten': ['mock-module-ep8.c'],
'mock-eleven': ['mock-module-ep9.c']
'mock-eleven': ['mock-module-ep9.c'],
'mock-thirteen': ['mock-module-ep11.c']
}

if host_system != 'windows'
Expand All @@ -430,7 +437,7 @@ if get_option('test')
name_suffix: module_suffix,
link_args: p11_module_ldflags,
link_depends: [p11_module_symbol_map],
dependencies: [libp11_test_dep])
dependencies: [libp11_test_dep] + libp11_asn1_deps)
endforeach
endif

Expand Down
Loading

0 comments on commit 673b7bb

Please sign in to comment.