From: Pedro Alves Date: Thu, 28 Sep 2017 21:31:42 +0000 (+0100) Subject: Move utils-selftests.c -> gdb/unittests/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b2f8eb7a30dcf7c33ea26dfca31401a6786dcd99;p=binutils-gdb.git Move utils-selftests.c -> gdb/unittests/ This file was only under gdb/ currently because it predates the gdb/unittests/ directory. gdb/ChangeLog: 2017-09-28 Pedro Alves * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/common-utils-selftests.c. (SUBDIR_UNITTESTS_OBS): Add common-utils-selftests.o. (COMMON_OBS): Remove utils-selftests.o. * utils-selftests.c: Move to ... * unittests/common-utils-selftests.c: ... here and rename self test to "string_printf". --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2120df65e9d..ab9250c8902 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2017-09-28 Pedro Alves + + * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add + unittests/common-utils-selftests.c. + (SUBDIR_UNITTESTS_OBS): Add common-utils-selftests.o. + (COMMON_OBS): Remove utils-selftests.o. + * utils-selftests.c: Move to ... + * unittests/common-utils-selftests.c: ... here and rename self + test to "string_printf". + 2017-09-28 Alexander Shaposhnikov (tiny patch) * dwarf2read.c (open_and_init_dwp_file): Protect against dwp_file diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 9004b350e4e..f3f1d404ba8 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -527,6 +527,7 @@ SUBDIR_PYTHON_CFLAGS = SUBDIR_UNITTESTS_SRCS = \ unittests/array-view-selftests.c \ + unittests/common-utils-selftests.c \ unittests/environ-selftests.c \ unittests/function-view-selftests.c \ unittests/offset-type-selftests.c \ @@ -537,6 +538,7 @@ SUBDIR_UNITTESTS_SRCS = \ SUBDIR_UNITTESTS_OBS = \ array-view-selftests.o \ + common-utils-selftests.o \ environ-selftests.o \ function-view-selftests.o \ offset-type-selftests.o \ @@ -1842,7 +1844,6 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ ui-out.o \ user-regs.o \ utils.o \ - utils-selftests.o \ valarith.o \ valops.o \ valprint.o \ diff --git a/gdb/unittests/common-utils-selftests.c b/gdb/unittests/common-utils-selftests.c new file mode 100644 index 00000000000..71bc2dff7f6 --- /dev/null +++ b/gdb/unittests/common-utils-selftests.c @@ -0,0 +1,50 @@ +/* Self tests for general utility routines for GDB, the GNU debugger. + + Copyright (C) 2016-2017 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "common-defs.h" +#include "selftest.h" + +namespace selftests { + +static void +string_printf_tests () +{ + SELF_CHECK (string_printf ("%s", "") == ""); + SELF_CHECK (string_printf ("%d comes before 2", 1) == "1 comes before 2"); + SELF_CHECK (string_printf ("hello %s", "world") == "hello world"); + +#define X10 "0123456789" +#define X100 X10 X10 X10 X10 X10 X10 X10 X10 X10 X10 +#define X1000 X100 X100 X100 X100 X100 X100 X100 X100 X100 X100 +#define X10000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 +#define X100000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 + SELF_CHECK (string_printf ("%s", X10) == X10); + SELF_CHECK (string_printf ("%s", X100) == X100); + SELF_CHECK (string_printf ("%s", X1000) == X1000); + SELF_CHECK (string_printf ("%s", X10000) == X10000); + SELF_CHECK (string_printf ("%s", X100000) == X100000); +} + +} /* namespace selftests */ + +void +_initialize_common_utils_selftests () +{ + selftests::register_test ("string_printf", selftests::string_printf_tests); +} diff --git a/gdb/utils-selftests.c b/gdb/utils-selftests.c deleted file mode 100644 index 5a30a93c9de..00000000000 --- a/gdb/utils-selftests.c +++ /dev/null @@ -1,60 +0,0 @@ -/* Self tests for general utility routines for GDB, the GNU debugger. - - Copyright (C) 2016-2017 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include "defs.h" -#include "selftest.h" - -#if GDB_SELF_TEST - -namespace selftests { - -/* common-utils self tests. Defined here instead of in - common/common-utils.c because that file is shared with - gdbserver. */ - -static void -common_utils_tests (void) -{ - SELF_CHECK (string_printf ("%s", "") == ""); - SELF_CHECK (string_printf ("%d comes before 2", 1) == "1 comes before 2"); - SELF_CHECK (string_printf ("hello %s", "world") == "hello world"); - -#define X10 "0123456789" -#define X100 X10 X10 X10 X10 X10 X10 X10 X10 X10 X10 -#define X1000 X100 X100 X100 X100 X100 X100 X100 X100 X100 X100 -#define X10000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 -#define X100000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 - SELF_CHECK (string_printf ("%s", X10) == X10); - SELF_CHECK (string_printf ("%s", X100) == X100); - SELF_CHECK (string_printf ("%s", X1000) == X1000); - SELF_CHECK (string_printf ("%s", X10000) == X10000); - SELF_CHECK (string_printf ("%s", X100000) == X100000); -} - -} /* namespace selftests */ - -#endif - -void -_initialize_utils_selftests (void) -{ -#if GDB_SELF_TEST - selftests::register_test ("common-utils", selftests::common_utils_tests); -#endif -}