Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ci_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
"numactl-dev"
]
},
"aws-c-sdkutils": {
"build_options": [
"aws-c-sdkutils:tests=enabled"
]
},
"argtable3": {
"build_options": [
"argtable3:examples=true",
Expand Down
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@
"0.3.1-1"
]
},
"aws-c-sdkutils": {
"dependency_names": [
"aws-c-sdkutils"
],
"versions": [
"0.2.4-1"
]
},
"backward-cpp": {
"dependency_names": [
"backward-cpp",
Expand Down
9 changes: 9 additions & 0 deletions subprojects/aws-c-sdkutils.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = aws-c-sdkutils-0.2.4
source_url = https://github.com/awslabs/aws-c-sdkutils/archive/refs/tags/v0.2.4.tar.gz
source_filename = aws-c-sdkutils-0.2.4.tar.gz
source_hash = 493cbed4fa57e0d4622fcff044e11305eb4fc12445f32c8861025597939175fc
patch_directory = aws-c-sdkutils

[provide]
dependency_names = aws-c-sdkutils
18 changes: 18 additions & 0 deletions subprojects/packagefiles/aws-c-sdkutils/generate_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3

import sys

# Usage: generate_tests.py <input test names file> <output C file>
if __name__ == '__main__':
with open(sys.argv[1], 'r') as test_names:
tests = [line.strip() for line in test_names if line.strip()]
with open(sys.argv[2], 'w') as out:
out.write('/* Auto-generated file, do not edit */\n\n#include <string.h>\n\n')
for name in tests:
out.write(f'extern int {name}(int argc, char **argv);\n')
out.write('\n')
out.write('int main(int argc, char **argv) {\n')
for name in tests:
out.write(f' if (strcmp(argv[1], "{name}") == 0) return {name}(argc, argv);\n')
out.write(' return 0;\n')
out.write('}\n')
9 changes: 9 additions & 0 deletions subprojects/packagefiles/aws-c-sdkutils/include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
install_headers(
'aws/sdkutils/aws_profile.h',
'aws/sdkutils/endpoints_rule_engine.h',
'aws/sdkutils/exports.h',
'aws/sdkutils/partitions.h',
'aws/sdkutils/resource_name.h',
'aws/sdkutils/sdkutils.h',
preserve_path: true,
)
92 changes: 92 additions & 0 deletions subprojects/packagefiles/aws-c-sdkutils/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
project(
'aws-c-sdkutils',
'c',
version: '0.2.4',
license: 'Apache-2.0',
meson_version: '>=0.64.0',

Check notice on line 6 in subprojects/packagefiles/aws-c-sdkutils/meson.build

View workflow job for this annotation

GitHub Actions / Ubuntu (x86_64)

Minimum Meson version is 0.64.0

0.56.0: oldest version supported by WrapDB 0.57.0: fs.read 0.59.0: feature_option.disable_auto_if() 0.63.0: preserve_path arg in install_headers 0.64.0: fs.copyfile
)

tests_opt = get_option('tests').disable_auto_if(meson.is_subproject())

pkg = import('pkgconfig')
fs = import('fs')

aws_c_common_dep = dependency('aws-c-common')

deps = [aws_c_common_dep]

src = files(
'source/aws_profile.c',
'source/endpoints_regex.c',
'source/endpoints_rule_engine.c',
'source/endpoints_ruleset.c',
'source/endpoints_standard_lib.c',
'source/endpoints_types_impl.c',
'source/endpoints_util.c',
'source/partitions.c',
'source/resource_name.c',
'source/sdkutils.c',
)

subdir('include')

inc = include_directories('include')

c_args = ['-DAWS_SDKUTILS_EXPORTS=1']
public_c_args = []
if (
get_option('default_library') == 'shared'
and host_machine.system() == 'windows'
) or host_machine.system() != 'windows'
public_c_args += ['-DAWS_SDKUTILS_USE_IMPORT_EXPORT=1']
endif

libaws_c_sdkutils = library(
'aws-c-sdkutils',
src,
c_args: c_args + public_c_args,
include_directories: inc,
dependencies: deps,
install: true,
version: meson.project_version(),
gnu_symbol_visibility: 'hidden',
)

aws_c_sdkutils_dep = declare_dependency(
include_directories: inc,
link_with: libaws_c_sdkutils,
dependencies: deps,
compile_args: public_c_args,
)

meson.override_dependency('aws-c-sdkutils', aws_c_sdkutils_dep)

pkg.generate(
libaws_c_sdkutils,
extra_cflags: public_c_args,
description: 'C99 library implementing AWS SDK specific utilities. Includes utilities for ARN parsing, reading AWS profiles, etc...',
)

generate_tests = find_program(
'generate_tests.py',
required: tests_opt,
)
run_test = find_program(
'run_test.py',
required: tests_opt,
)

if generate_tests.found() and run_test.found()
# aws-c-sdkutils uses an obscure cmake feature `create_test_sourcelist` to generate test harnesses
# this is a best effort approximation of that behavior
test_harness_src = custom_target(
'generate_test_harness',
input: 'tests.txt',
output: 'test_harness.c',
command: [generate_tests, '@INPUT@', '@OUTPUT@'],
)

names = fs.read('tests.txt').split('\n')

subdir('tests')
endif
5 changes: 5 additions & 0 deletions subprojects/packagefiles/aws-c-sdkutils/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
option(
'tests',
type: 'feature',
description: 'Build unit tests',
)
14 changes: 14 additions & 0 deletions subprojects/packagefiles/aws-c-sdkutils/run_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3

import sys
import os

# Usage: run_test.py <test exe> [args...]
if __name__ == '__main__':
test_exe = sys.argv[1]
test_args = sys.argv[2:]
import subprocess
result = subprocess.run([test_exe] + test_args, cwd = os.getcwd())
if result.returncode == 103:
result.returncode = 77 # Skip code for meson
sys.exit(result.returncode)
87 changes: 87 additions & 0 deletions subprojects/packagefiles/aws-c-sdkutils/tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
sdkutils_library_test
aws_profile_early_property_parse_failure_test
aws_profile_missing_bracket_parse_failure_test
aws_profile_missing_assignment_parse_failure_test
aws_profile_missing_property_key_parse_failure_test
aws_profile_early_continuation_parse_failure_test
aws_profile_illegal_continuation1_parse_failure_test
aws_profile_illegal_continuation2_parse_failure_test
aws_profile_illegal_continuation3_parse_failure_test
aws_profile_continuation_reset_on_new_profile_parse_failure_test
aws_profile_empty_test
aws_profile_empty_profile_test
aws_profile_whitespace_empty_profile_test
aws_profile_tab_empty_profile_test
aws_profile_single_simple_property_profile_test
aws_profile_equal_containing_property_profile_test
aws_profile_unicode_containing_property_profile_test
aws_profile_multiple_property_profile_test
aws_profile_trimmable_property_profile_test
aws_profile_empty_property_profile_test
aws_profile_multiple_empty_profile_test
aws_profile_multiple_profile_test
aws_profile_multiple_sections
aws_profile_sections_in_credentials_test
aws_profile_sso_session_without_name_test
aws_profile_services_invalid_prefix_test
aws_profile_blank_lines_ignored_test
aws_profile_pound_comments_ignored_test
aws_profile_semicolon_comments_ignored_test
aws_profile_mixed_comments_ignored_test
aws_profile_empty_comments_ignored_test
aws_profile_profile_adjacent_comment_test
aws_profile_value_adjacent_comment_test
aws_profile_continued_property_value_test
aws_profile_multiline_continued_property_value_test
aws_profile_continued_property_value_trim_test
aws_profile_continued_property_value_pound_comment_test
aws_profile_continued_property_value_semicolon_comment_test
aws_profile_duplicate_profiles_merge_test
aws_profile_duplicate_properties_last_property_value_test
aws_profile_duplicate_profiles_last_property_value_test
aws_profile_duplicate_default_profiles_property_resolution1_test
aws_profile_duplicate_default_profiles_property_resolution2_test
aws_profile_invalid_profile_names_merge_test
aws_profile_invalid_property_names_ignored_test
aws_profile_all_valid_profile_characters_test
aws_profile_all_valid_property_characters_test
aws_profile_basic_sub_property_test
aws_profile_empty_sub_property_test
aws_profile_invalid_sub_property_name_test
aws_profile_sub_property_blank_line_test
aws_profile_basic_duplicate_merge_test
aws_profile_mixed_prefix_default_test
aws_profile_override_duplicate_merge_test
aws_profile_no_prefix_nondefault_test
aws_profile_prefix_credentials_test
parse_resource_name_test
parse_resource_name_failures_test
resource_name_tostring_test
resource_name_tostring_failure_test
resource_name_length_test
parse_ruleset_from_string
test_endpoints_aws_region
test_endpoints_default_values
test_endpoints_eventbridge
test_endpoints_fns
test_endpoints_get_attr_type_inference
test_endpoints_headers
test_endpoints_is_virtual_hostable_s3_bucket
test_endpoints_region_override
test_endpoints_minimal_ruleset
test_endpoints_parse_arn
test_endpoints_parse_url
test_endpoints_partition_fn
test_endpoints_substring
test_endpoints_uri_encode
test_endpoints_valid_hostlabel
test_endpoints_condition_mem_clean_up
test_endpoints_custom
test_endpoints_string_array
test_endpoints_malformed_no_required_default
test_endpoints_malformed_regex
endpoints_uri_normalize_path
endpoints_byte_buf_init_from_resolved_templated_string
endpoints_regex_aws_region_matches
endpoints_regex_iso_region_matches
endpoints_regex_misc_validation
50 changes: 50 additions & 0 deletions subprojects/packagefiles/aws-c-sdkutils/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
test_src = files(
'aws_profile_parser_tests.c',
'aws_profile_tests.c',
'endpoints_regex_tests.c',
'endpoints_rule_engine_tests.c',
'endpoints_util_tests.c',
'resource_name_tests.c',
'sdkutils_test.c',
)

libtestcases = static_library(
'aws_c_sdkutils_testcases',
test_src,
dependencies: [aws_c_sdkutils_dep],
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
include_directories: inc,
build_by_default: false,
)

test_harness = executable(
'aws-c-sdkutils-tests',
test_harness_src,
dependencies: [aws_c_sdkutils_dep],
link_with: [libtestcases],
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
include_directories: inc,
build_by_default: false,
)

# aws-c-commons test harness has some very unfortunate behaviour on windows
# where it changes the working directory to the test executable's directory before running the test,
# so we need to copy all the test resources to the build directory or the tests cant find them.
# see https://github.com/awslabs/aws-c-common/blob/main/include/aws/testing/aws_test_harness.h#L407-L416
copied = []

subdir('resources/malformed-rules')
subdir('resources/test-cases')
subdir('resources/valid-rules')
subdir('resources')

foreach name : names
test(
name,
run_test,
args: [test_harness.full_path(), name],
workdir: meson.current_build_dir() / 'resources',
timeout: 600,
depends: [test_harness, copied],
)
endforeach
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources = files(
'no_default_on_required.json',
)

foreach name : resources
copied += fs.copyfile(name)
endforeach
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resources = files(
'partitions.json',
'sample_partitions.json',
'sample_partitions_bad_regex.json',
'sample_ruleset.json',
)

foreach name : resources
copied += fs.copyfile(name)
endforeach

test_harness = executable(
'aws-c-sdkutils-tests',
test_harness_src,
dependencies: [aws_c_sdkutils_dep],
link_with: [libtestcases],
c_args: ['-DAWS_UNSTABLE_TESTING_API=1'],
include_directories: inc,
build_by_default: false,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resources = files(
'aws-region.json',
'custom_object_condition.json',
'custom_partition.json',
'default-values.json',
'eventbridge.json',
'fns.json',
'headers.json',
'is-virtual-hostable-s3-bucket.json',
'local-region-override.json',
'parse-arn.json',
'parse-url.json',
'partition-fn.json',
'string_array.json',
'substring.json',
'uri-encode.json',
'valid-hostlabel.json',
)

foreach name : resources
copied += fs.copyfile(name)
endforeach
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resources = files(
'aws-region.json',
'custom_object_condition.json',
'custom_partition.json',
'default-values.json',
'deprecated-param.json',
'eventbridge.json',
'fns.json',
'get-attr-type-inference.json',
'headers.json',
'is-virtual-hostable-s3-bucket.json',
'minimal-ruleset.json',
'parse-arn.json',
'parse-url.json',
'partition-fn.json',
'region-override.json',
'string_array.json',
'substring.json',
'uri-encode.json',
'valid-hostlabel.json',
)

foreach name : resources
copied += fs.copyfile(name)
endforeach
Loading
Loading