From: nasm-bot f. C. G. <gor...@gm...> - 2018-11-24 14:09:19
|
Commit-ID: f6b1720a2d11af83c659e41d988f472f041b0088 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=f6b1720a2d11af83c659e41d988f472f041b0088 Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sat, 24 Nov 2018 16:33:18 +0300 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sat, 24 Nov 2018 16:59:32 +0300 version: Make them dynamic for regression tests sake When we are running regression tests we compare binary forms and the strings better to be the constants to not trigger false positives. Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- include/ver.h | 10 ++++++++-- nasmlib/ver.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- output/outelf.c | 6 +++--- output/outieee.c | 2 +- output/outmacho.c | 2 +- output/outobj.c | 2 +- 6 files changed, 56 insertions(+), 10 deletions(-) diff --git a/include/ver.h b/include/ver.h index 62d9c52..dfc4c6a 100644 --- a/include/ver.h +++ b/include/ver.h @@ -41,7 +41,13 @@ extern const char nasm_version[]; extern const char nasm_date[]; extern const char nasm_compile_options[]; -extern const char nasm_comment[]; -extern const char nasm_signature[]; + +extern const char *nasm_comment(void); +extern size_t nasm_comment_len(void); + +extern const char *nasm_signature(void); +extern size_t nasm_signature_len(void); + +extern int nasm_test_run(void); #endif /* NASM_VER_H */ diff --git a/nasmlib/ver.c b/nasmlib/ver.c index 98362e3..b1638b7 100644 --- a/nasmlib/ver.c +++ b/nasmlib/ver.c @@ -31,6 +31,9 @@ * * ----------------------------------------------------------------------- */ +#include <stdlib.h> +#include <string.h> + #include "ver.h" #include "version.h" @@ -44,8 +47,45 @@ const char nasm_compile_options[] = "" ; /* These are used by some backends. */ -const char nasm_comment[] = +static const char __nasm_comment[] = "The Netwide Assembler " NASM_VER; -const char nasm_signature[] = +static const char __nasm_signature[] = "NASM " NASM_VER; + +/* These are constant so we could pass regression tests */ +static const char __nasm_comment_const[] ="The Netwide Assembler CONST"; +static const char __nasm_signature_const[] = "NASM CONST"; + +int nasm_test_run(void) +{ + return getenv("NASM_TEST_RUN") ? 1 : 0; +} + +const char *nasm_comment(void) +{ + if (!nasm_test_run()) + return __nasm_comment; + return __nasm_comment_const; +} + +size_t nasm_comment_len(void) +{ + if (!nasm_test_run()) + return strlen(__nasm_comment); + return strlen(__nasm_comment_const); +} + +const char *nasm_signature(void) +{ + if (!nasm_test_run()) + return __nasm_signature; + return __nasm_signature_const; +} + +size_t nasm_signature_len(void) +{ + if (!nasm_test_run()) + return strlen(__nasm_signature); + return strlen(__nasm_signature_const); +} diff --git a/output/outelf.c b/output/outelf.c index d8a5541..e3e3a68 100644 --- a/output/outelf.c +++ b/output/outelf.c @@ -2996,7 +2996,7 @@ static void dwarf_generate(void) saa_write32(pinforel, 0); saa_write32(pinfo,0); /* DW_AT_stmt_list */ saa_wbytes(pinfo, elf_module, strlen(elf_module)+1); - saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1); + saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1); saa_write16(pinfo,DW_LANG_Mips_Assembler); saa_write8(pinfo,2); /* abbrviation number LEB128u */ saa_write32(pinforel, pinfo->datalen + 4); @@ -3035,7 +3035,7 @@ static void dwarf_generate(void) saa_write32(pinforel, 0); saa_write32(pinfo,0); /* DW_AT_stmt_list */ saa_wbytes(pinfo, elf_module, strlen(elf_module)+1); - saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1); + saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1); saa_write16(pinfo,DW_LANG_Mips_Assembler); saa_write8(pinfo,2); /* abbrviation number LEB128u */ saa_write32(pinforel, pinfo->datalen + 4); @@ -3075,7 +3075,7 @@ static void dwarf_generate(void) saa_write64(pinforel, 0); saa_write32(pinfo,0); /* DW_AT_stmt_list */ saa_wbytes(pinfo, elf_module, strlen(elf_module)+1); - saa_wbytes(pinfo, nasm_signature, strlen(nasm_signature)+1); + saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1); saa_write16(pinfo,DW_LANG_Mips_Assembler); saa_write8(pinfo,2); /* abbrviation number LEB128u */ saa_write64(pinforel, pinfo->datalen + 4); diff --git a/output/outieee.c b/output/outieee.c index 211cdab..ce4830d 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -893,7 +893,7 @@ static void ieee_write_file(void) /* * Write the NASM boast comment. */ - ieee_putascii("CO0,%02X%s.\n", strlen(nasm_comment), nasm_comment); + ieee_putascii("CO0,%02X%s.\n", nasm_comment_len(), nasm_comment()); /* * write processor-specific information diff --git a/output/outmacho.c b/output/outmacho.c index 769aac0..14aec07 100644 --- a/output/outmacho.c +++ b/output/outmacho.c @@ -1950,7 +1950,7 @@ static void macho_dbg_generate(void) nasm_assert(p_section != NULL); producer_str_offset = 0; - module_str_offset = dir_str_offset = saa_wcstring(p_str, nasm_signature); + module_str_offset = dir_str_offset = saa_wcstring(p_str, nasm_signature()); dir_str_offset += saa_wcstring(p_str, cur_file); saa_wcstring(p_str, cur_dir); diff --git a/output/outobj.c b/output/outobj.c index b766c54..1caaf20 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -1981,7 +1981,7 @@ static void obj_write_file(void) */ orp->type = COMENT; obj_rword(orp, dTRANSL); - obj_name(orp, nasm_comment); + obj_name(orp, nasm_comment()); obj_emit2(orp); /* |