Skip to content

Commit

Permalink
attempt to get unit tests working on cygwin
Browse files Browse the repository at this point in the history
The change adds 'enable-dos2unix' build configuration option. After enabling
unit test in cygwin-like test worflow I could see `util/shlib_wrap.sh` fails
to run. One of the error was:
```
./../util/../util/shlib_wrap.sh: line 2: $'\r': command not found
```
It smells like some CRLF vsl LF (dos vs. unix) line terminators.
Looks like cygwin on windows is still sensitive to this.

The newly added `enable-dos2unix` makes sure all .sh/.pl scripts generated
at build time will have unix (LF) line end terminator. We use dos2unix
tool to convert generated script.

The cygwin windows workflow on github then should use option
`enable-dos2unix` if it plans to run unit tests. I could not
figure out how to do it in workflow only, therefore I'm alos
extending the OpenSSL build configuration.
  • Loading branch information
Sashan committed Apr 21, 2024
1 parent 540bc81 commit 3f0be53
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 7 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/windows.yml
Expand Up @@ -183,3 +183,67 @@ jobs:
# Disable testing for now. TBD: Need local cygwin installation to debug .
# - name: Run openssl tests
# run: bash -c "cd openssl && make V=1 test"
mingw:
# Run a job for each of the specified target architectures:
# copied and modified from shared. Instead of installing nasm we
# install mingw and cygwin.
#
strategy:
matrix:
os:
- windows-2022
platform:
- arch: win64
config: enable-tests no-fips enable-dos2unix
runs-on: ${{ github.server_url == 'https://github.com' && matrix.os || format('{0}-self-hosted', matrix.os) }}
steps:
- uses: actions/checkout@v4
- uses: cygwin/cygwin-install-action@master
with:
packages: perl git make gcc-core gcc dos2unix
- name: Check repo
run: cygcheck -V
- name: Full cygcheck status
run: cygcheck -s -v -r -h
- name: Install MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
cygwin: 1
- name: prepare the build directory
run: mkdir _build
- name: config
working-directory: _build
run: |
bash -c "gcc --version && perl ../Configure ${{ matrix.platform.config }}"
bash -c "perl configdata.pm --dump"
- name: build
working-directory: _build
run: |
bash -c "make -j 4"
- name: download coreinfo
uses: suisei-cn/actions-download-file@v1.6.0
with:
url: "https://download.sysinternals.com/files/Coreinfo.zip"
target: _build/coreinfo/
- name: get cpu info
working-directory: _build
continue-on-error: true
run: |
7z.exe x coreinfo/Coreinfo.zip
./Coreinfo64.exe -accepteula -f
./apps/openssl.exe version -c
- name: Check platform symbol usage
working-directory: _build
run: perl ../util/checkplatformsyms.pl ../util/platform_symbols/windows-symbols.txt libcrypto-3-x64.dll ./libssl-3-x64.dll
- name: test
working-directory: _build
run: |
bash -c "make test HARNESS_JOBS=4"
- name: save artifacts
uses: actions/upload-artifact@v3
with:
name: "ci@-${{ matrix.os }}"
path: _build
if-no-files-found: ignore
retention-days: 2
18 changes: 11 additions & 7 deletions Configurations/unix-Makefile.tmpl
Expand Up @@ -2011,13 +2011,17 @@ EOF
my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "dofile.pl")),
rel2abs($config{builddir}));
return <<"EOF";
$script: $sources configdata.pm
\$(RM) "$script"
\$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
"-o$target{build_file}" $sources > "$script"
chmod a+x $script
EOF
my $rv;
$rv .= "$script: $sources configdata.pm\n";
$rv .= "\t\$(RM) \"$script\"\n";
$rv .= "\t\$(PERL) \"-I\$(BLDDIR)\" -Mconfigdata \"$dofile\" \\\n";
$rv .= "\t \"-o$target{build_file}\" $sources > \"$script\"\n";
# if ($config{dos2unix} == 1 && $script =~ /.+\.sh$/) {
if ($config{dos2unix} == 1) {
$rv .= "\tdos2unix $script \n";
}
$rv .= "\tchmod a+x $script\n";
return $rv;
}
sub generatedir {
my %args = @_;
Expand Down
5 changes: 5 additions & 0 deletions Configure
Expand Up @@ -455,6 +455,7 @@ my @disablables = (
"dgram",
"dh",
"docs",
"dos2unix",
"dsa",
"dso",
"dtls",
Expand Down Expand Up @@ -865,6 +866,10 @@ while (@argvcopy)
$unsupported_options{$_} = 1;
next;
}
elsif ($word =~ /dos2unix/)
{
$config{dos2unix} = 1; # .sh scripts on cygwin windows needs to be converted to unix form
}
}
if (/^no-(.+)$/ || /^disable-(.+)$/)
{
Expand Down

0 comments on commit 3f0be53

Please sign in to comment.