Skip to content

Commit

Permalink
Smart I/O test: do not mix files compiled with smart I/O and files co…
Browse files Browse the repository at this point in the history
…mpiled without it in the same firmware

It does not work in v1.25
  • Loading branch information
fabio-d committed Jun 28, 2020
1 parent 786e546 commit beea4e8
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 35 deletions.
2 changes: 1 addition & 1 deletion VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ compiler options, replace them respectively with `-std=gnu++98` or
- [Microchip's XC16 v1.36 Linux installer](http://ww1.microchip.com/downloads/en/DeviceDoc/xc16-v1.36b-full-install-linux-installer.run) (sha1 8103cca06d65b849c153c39513b1a6df58fa0bf2)
- [Microchip's XC16 v1.36 Windows installer](http://ww1.microchip.com/downloads/en/DeviceDoc/xc16-v1.36b-full-install-windows-installer.exe) (sha1 0f49032de26af810aa90265b6d4385496d5ac7e7)
- [Microchip's XC16 v1.36 OSX installer](http://ww1.microchip.com/downloads/en/DeviceDoc/xc16-v1.36b-full-install-osx-installer.dmg) (sha1 0095ee545343121ed2668cc0899e0d5cfb4d4c0a)
- [Microchip's XC16 v1.36 source archive](http://ww1.microchip.com/downloads/Secure/en/DeviceDoc/v1.36b.src.zip) (sha1 29dc4f8bb42fae9682f1548993885be3556a891e)
- [Microchip's XC16 v1.36 source archive](http://ww1.microchip.com/downloads/Secure/en/DeviceDoc/v1.36b.src.zip) (sha1 ad44b387b3a5859a8f8755190c427e26b02252f4)

## v1.40

Expand Down
7 changes: 0 additions & 7 deletions autotests/15-smartio/disabled_smartio.cpp

This file was deleted.

1 change: 0 additions & 1 deletion autotests/15-smartio/expected_output-with-longlong.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
test no-smart-io
test arg none
test c c
test xyz xyz
Expand Down
1 change: 0 additions & 1 deletion autotests/15-smartio/expected_output-without-longlong.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
test no-smart-io
test arg none
test c c
test xyz xyz
Expand Down
4 changes: 1 addition & 3 deletions autotests/15-smartio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

int main (int argc, char *argv[])
{
do_disabled_smartio();

do_arg_none();
do_arg_char();
do_arg_string();
do_arg_int();
do_arg_float();
do_arg_float_and_string();

#if __XC16_VERSION__ >= 1030
#if WITH_LONGLONG
do_arg_longlong();
#endif

Expand Down
62 changes: 43 additions & 19 deletions autotests/15-smartio/testdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@

THIS_DIR = os.path.abspath(os.path.dirname(__file__))

EXPECTED_SYMBOLS = {
'disabled_smartio.o': '_printf',
'arg_none.o': '_puts',
'arg_char.o': '__printf_cdnopuxX',
'arg_string.o': '__printf_s',
'arg_int.o': '__printf_cdnopuxX',
'arg_float.o': '__printf_fF',
'arg_float_and_string.o': '__printf_fFs',
'arg_longlong.o': '__printf_cdnopuxXL'
}

# Notes on the LONGLONG modifier:
# - It is only supported since v1.30
# - It only works if smart I/O is enabled

@register_test(omf=['elf', 'coff'])
class MyTest(Test):
class _BaseTestSmartIOTest(Test):
def __init__(self, omf):
self.omf = omf

Expand Down Expand Up @@ -56,22 +48,22 @@ def compile(self, compilation_env):
]

# The L modifier is only supported since v1.30
if compilation_env.compiler_version >= (1, 30):
if compilation_env.compiler_version >= (1, 30) \
and not self.skip_longlong:
with_longlong = True
source_files_default_opts.append(
os.path.join(THIS_DIR, 'arg_longlong.cpp'))
else:
with_longlong = False

# Compile all files with standard flags, except for disabled_smartio.cpp
prj.source_files = {fn: [] for fn in source_files_default_opts}
prj.source_files[os.path.join(THIS_DIR, 'disabled_smartio.cpp')] \
= ['-msmart-io=0'] # disable smart I/O for this file
opts = [*self.default_opts, '-DWITH_LONGLONG=%d' % with_longlong]
prj.source_files = {fn: opts
for fn in source_files_default_opts}

compiler_output = prj.build()
if compiler_output.success:
files_to_be_checked = \
set(EXPECTED_SYMBOLS) & set(compiler_output.output_files)
set(self.EXPECTED_SYMBOLS) & set(compiler_output.output_files)

# Extract object files
with tempfile.TemporaryDirectory() as tmpdir:
Expand All @@ -87,7 +79,8 @@ def compile(self, compilation_env):

as_expected = True
for file_name in printf_symbols:
if printf_symbols[file_name] != [EXPECTED_SYMBOLS[file_name]]:
expected_symbol = self.EXPECTED_SYMBOLS[file_name]
if printf_symbols[file_name] != [expected_symbol]:
print('Expected symbol mismatch!', file_name)
as_expected = False

Expand Down Expand Up @@ -120,3 +113,34 @@ def validate(self, validation_env, compilation_output):
final_outcome=Outcome.PASSED if good else Outcome.FAILED,
files={'uart.txt': out.uart_output})


@register_test(omf=['elf', 'coff'])
class TestWithSmartIO(_BaseTestSmartIOTest):
default_opts = []
skip_longlong = False

EXPECTED_SYMBOLS = {
'arg_none.o': '_puts',
'arg_char.o': '__printf_cdnopuxX',
'arg_string.o': '__printf_s',
'arg_int.o': '__printf_cdnopuxX',
'arg_float.o': '__printf_fF',
'arg_float_and_string.o': '__printf_fFs',
'arg_longlong.o': '__printf_cdnopuxXL'
}


@register_test(omf=['elf', 'coff'])
class TestWithoutSmartIO(_BaseTestSmartIOTest):
default_opts = ['-msmart-io=0'] # disable smart I/O
skip_longlong = True # it seems to be unsupported by the regular printf

EXPECTED_SYMBOLS = {
'arg_none.o': '_puts',
'arg_char.o': '_printf',
'arg_string.o': '_printf',
'arg_int.o': '_printf',
'arg_float.o': '_printf',
'arg_float_and_string.o': '_printf',
'arg_longlong.o': '_printf'
}
4 changes: 1 addition & 3 deletions autotests/15-smartio/variants.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#pragma once

void do_disabled_smartio();

void do_arg_none();
void do_arg_char();
void do_arg_string();
void do_arg_int();
void do_arg_float();
void do_arg_float_and_string();

#if __XC16_VERSION__ >= 1030 // v1.30+ only
#if WITH_LONGLONG
void do_arg_longlong();
#endif

0 comments on commit beea4e8

Please sign in to comment.