-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests to check shared object contents #693
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#! /bin/sh | ||
|
||
# Script to test that all the symbols of a shared object are as expected. | ||
|
||
set -e | ||
|
||
LANG=C # Ensure stable ordering of `sort` output | ||
export LANG | ||
|
||
if [ "$1" = "" -o "$2" = "" ] ; then | ||
echo "Usage: $0 <so_dir> <manifest_dir>" >&2 | ||
exit 1 | ||
fi | ||
|
||
input_dir="$1" | ||
manifest_dir="$2" | ||
|
||
sed=sed | ||
grep=grep | ||
# Helpers for Solaris | ||
if [ -f /usr/bin/gsed ] ; then | ||
sed=/usr/bin/gsed | ||
fi | ||
if [ -f /usr/bin/ggrep ] ; then | ||
grep=/usr/bin/ggrep | ||
fi | ||
|
||
nm="nm -B -D" | ||
if [ "`uname -s`" = "SunOS" ]; then | ||
nm="nm -p -h -D -g" | ||
elif [ "`uname -s`" = "Darwin" ]; then | ||
nm="nm -B -g" | ||
fi | ||
|
||
so_ext=so | ||
so_mangling() { cat; } | ||
if [ "`uname -s`" = "Darwin" ]; then | ||
so_ext=dylib | ||
so_mangling() | ||
{ | ||
sed -E -e 's/_([_0-9a-zA-Z]+)$/\1/g' | ||
} | ||
fi | ||
|
||
for so_name in "libpcre2-8" "libpcre2-16" "libpcre2-32" "libpcre2-posix"; do | ||
expected_file="$manifest_dir/manifest-$so_name.so" | ||
so_file="$input_dir/$so_name.$so_ext" | ||
base=`basename $expected_file` | ||
|
||
$nm "$so_file" | \ | ||
$sed -E -e 's/^[0-9a-fA-F]* *//g' | \ | ||
$grep -E -v '^[Uw] ' | \ | ||
$grep -E -v ' (_init|_fini)$' | \ | ||
$grep -E -v ' (_end|_DYNAMIC|_GLOBAL_OFFSET_TABLE_|_PROCEDURE_LINKAGE_TABLE_|_edata|_etext)$' | \ | ||
so_mangling | \ | ||
sort \ | ||
> "$base" | ||
|
||
if ! diff -u "$expected_file" "$base"; then | ||
echo "Shared object contents for $so_file differ from expected" >&2 | ||
|
||
echo "===Actual===" >&2 | ||
cat "$base" >&2 | ||
echo "===End===" >&2 | ||
|
||
exit 1 | ||
fi | ||
|
||
echo "Shared object contents for $so_file match expected" | ||
rm -f "$base" | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Script to test that all the symbols of a DLL are as expected. | ||
|
||
param ( | ||
[Parameter(Mandatory=$true)] | ||
[string]$inputDir, | ||
|
||
[Parameter(Mandatory=$true)] | ||
[string]$manifestDir | ||
) | ||
|
||
if ((-not $inputDir) -or (-not $manifestDir)) { | ||
throw "Usage: .\RunSymbolTest.ps1 <dll_dir> <manifest_dir>" | ||
} | ||
|
||
$dllNames = @("pcre2-8", "pcre2-16", "pcre2-32", "pcre2-posix") | ||
|
||
foreach ($dllName in $dllNames) { | ||
$expectedFile = Join-Path $manifestDir ("manifest-lib$dllName.so") | ||
$dllFile = Join-Path $inputDir ("$dllName.dll") | ||
$base = [System.IO.Path]::GetFileName($expectedFile) | ||
|
||
# Get path to dumpbin using vswhere | ||
$vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" | ||
$dumpbin = & $vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find VC\Tools\MSVC\*\bin\Hostx64\x64\dumpbin.exe | Select-Object -First 1 | ||
|
||
$actualSymbols = & $dumpbin /exports $dllFile | | ||
ForEach-Object { | ||
if ($_ -match '^\s*\d+\s+[0-9A-Fa-f]+\s+[0-9A-Fa-f]+\s+(\S+)') { | ||
"T $($matches[1])" | ||
} | ||
} | | ||
Where-Object { | ||
$_ -match '^T ' | ||
} | | ||
Sort-Object | ||
|
||
$actualOutput = ($actualSymbols -join "`n") + "`n" | ||
$null = New-Item -Force $base -Value $actualOutput | ||
|
||
$expectedOutput = Get-Content -Path $expectedFile -Raw | ||
$actualOutput = Get-Content -Path $base -Raw | ||
|
||
if ($expectedOutput -ne $actualOutput) { | ||
Write-Host "Shared object contents for $dllFile differ from expected" | ||
Write-Host "===Actual===" | ||
Write-Host $actualOutput | ||
Write-Host "===End===" | ||
throw "Symbol test failed" | ||
} else { | ||
Write-Host "Shared object contents for $dllFile match expected" | ||
} | ||
|
||
Remove-Item -Path $base -Force | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
T pcre2_callout_enumerate_16 | ||
T pcre2_code_copy_16 | ||
T pcre2_code_copy_with_tables_16 | ||
T pcre2_code_free_16 | ||
T pcre2_compile_16 | ||
T pcre2_compile_context_copy_16 | ||
T pcre2_compile_context_create_16 | ||
T pcre2_compile_context_free_16 | ||
T pcre2_config_16 | ||
T pcre2_convert_context_copy_16 | ||
T pcre2_convert_context_create_16 | ||
T pcre2_convert_context_free_16 | ||
T pcre2_converted_pattern_free_16 | ||
T pcre2_dfa_match_16 | ||
T pcre2_general_context_copy_16 | ||
T pcre2_general_context_create_16 | ||
T pcre2_general_context_free_16 | ||
T pcre2_get_error_message_16 | ||
T pcre2_get_mark_16 | ||
T pcre2_get_match_data_heapframes_size_16 | ||
T pcre2_get_match_data_size_16 | ||
T pcre2_get_ovector_count_16 | ||
T pcre2_get_ovector_pointer_16 | ||
T pcre2_get_startchar_16 | ||
T pcre2_jit_compile_16 | ||
T pcre2_jit_free_unused_memory_16 | ||
T pcre2_jit_match_16 | ||
T pcre2_jit_stack_assign_16 | ||
T pcre2_jit_stack_create_16 | ||
T pcre2_jit_stack_free_16 | ||
T pcre2_maketables_16 | ||
T pcre2_maketables_free_16 | ||
T pcre2_match_16 | ||
T pcre2_match_context_copy_16 | ||
T pcre2_match_context_create_16 | ||
T pcre2_match_context_free_16 | ||
T pcre2_match_data_create_16 | ||
T pcre2_match_data_create_from_pattern_16 | ||
T pcre2_match_data_free_16 | ||
T pcre2_pattern_convert_16 | ||
T pcre2_pattern_info_16 | ||
T pcre2_serialize_decode_16 | ||
T pcre2_serialize_encode_16 | ||
T pcre2_serialize_free_16 | ||
T pcre2_serialize_get_number_of_codes_16 | ||
T pcre2_set_bsr_16 | ||
T pcre2_set_callout_16 | ||
T pcre2_set_character_tables_16 | ||
T pcre2_set_compile_extra_options_16 | ||
T pcre2_set_compile_recursion_guard_16 | ||
T pcre2_set_depth_limit_16 | ||
T pcre2_set_glob_escape_16 | ||
T pcre2_set_glob_separator_16 | ||
T pcre2_set_heap_limit_16 | ||
T pcre2_set_match_limit_16 | ||
T pcre2_set_max_pattern_compiled_length_16 | ||
T pcre2_set_max_pattern_length_16 | ||
T pcre2_set_max_varlookbehind_16 | ||
T pcre2_set_newline_16 | ||
T pcre2_set_offset_limit_16 | ||
T pcre2_set_optimize_16 | ||
T pcre2_set_parens_nest_limit_16 | ||
T pcre2_set_recursion_limit_16 | ||
T pcre2_set_recursion_memory_management_16 | ||
T pcre2_set_substitute_callout_16 | ||
T pcre2_set_substitute_case_callout_16 | ||
T pcre2_substitute_16 | ||
T pcre2_substring_copy_byname_16 | ||
T pcre2_substring_copy_bynumber_16 | ||
T pcre2_substring_free_16 | ||
T pcre2_substring_get_byname_16 | ||
T pcre2_substring_get_bynumber_16 | ||
T pcre2_substring_length_byname_16 | ||
T pcre2_substring_length_bynumber_16 | ||
T pcre2_substring_list_free_16 | ||
T pcre2_substring_list_get_16 | ||
T pcre2_substring_nametable_scan_16 | ||
T pcre2_substring_number_from_name_16 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carenas I think you know about this fix! We need to ship it in our CMakeLists, if we want to support the version of CMake that's shipped by Oracle and their latest Oracle Developer Studio.