Changeset 7c4b26c in mainline


Ignore:
Timestamp:
2016-05-02T21:30:14Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
91e4567
Parents:
32573ff
Message:

Dltest needs to test direct linking. Dltests to only test dlfcn. Need to dynamically link dltest even if using static base libs.

Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r32573ff r7c4b26c  
    3535uspace/app/devctl/devctl
    3636uspace/app/dltest/dltest
     37uspace/app/dltests/dltests
    3738uspace/app/dnscfg/dnscfg
    3839uspace/app/dnsres/dnsres
     
    9697uspace/dist/app/devctl
    9798uspace/dist/app/dltest
     99uspace/dist/app/dltests
    98100uspace/dist/app/dnscfg
    99101uspace/dist/app/dnsres
  • boot/Makefile.common

    r32573ff r7c4b26c  
    226226ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
    227227        RD_APPS_NON_ESSENTIAL += \
    228                 $(USPACE_PATH)/app/dltest/dltest
     228                $(USPACE_PATH)/app/dltest/dltest \
     229                $(USPACE_PATH)/app/dltests/dltests
    229230endif
    230231
  • uspace/Makefile

    r32573ff r7c4b26c  
    4141        app/corecfg \
    4242        app/devctl \
    43         app/dltest \
    4443        app/dnscfg \
    4544        app/dnsres \
     
    166165        drv/platform/icp
    167166
     167
    168168## Platform-specific hardware support
    169169#
     
    209209                drv/fb/amdm37x_dispc \
    210210                srv/hw/irc/icp-ic
     211endif
     212
     213## Dynamic linking tests
     214#
     215ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
     216        DIRS += \
     217                app/dltest \
     218                app/dltests
    211219endif
    212220
  • uspace/Makefile.common

    r32573ff r7c4b26c  
    199199ifeq ($(STATIC_BUILD),y)
    200200        BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
    201         LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
    202201        ifeq ($(MATH),y)
    203202                BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a
     
    205204else
    206205        BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 $(LIBSOFTINT_PREFIX)/libsoftint.so.0
    207         LFLAGS += -Bdynamic
    208         LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
     206        LINK_DYNAMIC = y
    209207        ifeq ($(MATH),y)
    210208                BASE_LIBS += $(LIBMATH_PREFIX)/libmath.so.0
    211209        endif
     210endif
     211
     212ifeq ($(LINK_DYNAMIC),y)
     213        LFLAGS += -Bdynamic
     214        LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
     215else
     216        LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
    212217endif
    213218
  • uspace/app/dltest/Makefile

    r32573ff r7c4b26c  
    2828
    2929USPACE_PREFIX = ../..
    30 EXTRA_CFLAGS = -I$(LIBDLTEST_PREFIX)
     30EXTRA_CFLAGS = -I$(LIBDLTEST_PREFIX) -DDLTEST_LINKED
     31LIBS = $(LIBDLTEST_PREFIX)/libdltest.so.0.0
     32# Need a dynamic link, but possibly still use static libc
     33LINK_DYNAMIC = y
     34
    3135BINARY = dltest
    3236
  • uspace/app/dltest/dltest.c

    r32573ff r7c4b26c  
    4545void *handle;
    4646
     47
    4748/** Test dlsym() function */
    4849static bool test_dlsym(void)
     
    255256}
    256257
     258#ifdef DLTEST_LINKED
     259
     260/** Test directly calling function that returns a constant */
     261static bool test_lnk_dl_get_constant(void)
     262{
     263        int val;
     264
     265        printf("Call linked dl_get_constant...\n");
     266
     267        val = dl_get_constant();
     268
     269        printf("Got %d, expected %d... ", val, dl_constant);
     270        if (val != dl_constant) {
     271                printf("FAILED\n");
     272                return false;
     273        }
     274
     275        printf("Passed\n");
     276        return true;
     277}
     278
     279/** Test dircetly calling a function that returns contents of a private
     280 * initialized variable.
     281 */
     282static bool test_lnk_dl_get_private_var(void)
     283{
     284        int val;
     285
     286        printf("Call linked dl_get_private_var...\n");
     287
     288        val = dl_get_private_var();
     289
     290        printf("Got %d, expected %d... ", val, dl_private_var_val);
     291        if (val != dl_private_var_val) {
     292                printf("FAILED\n");
     293                return false;
     294        }
     295
     296        printf("Passed\n");
     297        return true;
     298}
     299
     300/** Test dircetly calling a function that returns contents of a private
     301 * uninitialized variable.
     302 */
     303static bool test_lnk_dl_get_private_uvar(void)
     304{
     305        int val;
     306
     307        printf("Call linked dl_get_private_uvar...\n");
     308
     309        val = dl_get_private_uvar();
     310
     311        printf("Got %d, expected %d... ", val, 0);
     312        if (val != 0) {
     313                printf("FAILED\n");
     314                return false;
     315        }
     316
     317        printf("Passed\n");
     318        return true;
     319}
     320
     321/** Test directly calling a function that returns the contents of a public
     322 * initialized variable.
     323 */
     324static bool test_lnk_dl_get_public_var(void)
     325{
     326        int val;
     327
     328        printf("Call linked dl_get_public_var...\n");
     329
     330        val = dl_get_public_var();
     331
     332        printf("Got %d, expected %d... ", val, dl_public_var_val);
     333        if (val != dl_public_var_val) {
     334                printf("FAILED\n");
     335                return false;
     336        }
     337
     338        printf("Passed\n");
     339        return true;
     340}
     341
     342/** Test directly calling a function that returns the contents of a public
     343 * uninitialized variable.
     344 */
     345static bool test_lnk_dl_get_public_uvar(void)
     346{
     347        int val;
     348
     349        printf("Call linked dl_get_public_uvar...\n");
     350
     351        val = dl_get_public_uvar();
     352
     353        printf("Got %d, expected %d... ", val, 0);
     354        if (val != 0) {
     355                printf("FAILED\n");
     356                return false;
     357        }
     358
     359        printf("Passed\n");
     360        return true;
     361}
     362
     363/** Test directly reading a public initialized variable. */
     364static bool test_lnk_read_public_var(void)
     365{
     366        int val;
     367
     368        printf("Read linked dl_public_var...\n");
     369
     370        val = dl_public_var;
     371
     372        printf("Got %d, expected %d... ", val, dl_public_var_val);
     373        if (val != dl_public_var_val) {
     374                printf("FAILED\n");
     375                return false;
     376        }
     377
     378        printf("Passed\n");
     379        return true;
     380}
     381
     382/** Test directly reading a public uninitialized variable. */
     383static bool test_lnk_read_public_uvar(void)
     384{
     385        int val;
     386
     387        printf("Read linked dl_public_uvar...\n");
     388
     389        val = dl_public_uvar;
     390
     391        printf("Got %d, expected %d... ", val, 0);
     392        if (val != 0) {
     393                printf("FAILED\n");
     394                return false;
     395        }
     396
     397        printf("Passed\n");
     398        return true;
     399}
     400
     401#endif
     402
    257403int main(int argc, char *argv[])
    258404{
     
    293439                return 1;
    294440
     441#ifdef DLTEST_LINKED
     442        if (!test_lnk_dl_get_constant())
     443                return 1;
     444
     445        if (!test_lnk_dl_get_private_var())
     446                return 1;
     447
     448        if (!test_lnk_dl_get_private_uvar())
     449                return 1;
     450
     451        if (!test_lnk_dl_get_public_var())
     452                return 1;
     453
     454        if (!test_lnk_dl_get_public_uvar())
     455                return 1;
     456
     457        if (!test_lnk_read_public_var())
     458                return 1;
     459
     460        if (!test_lnk_read_public_uvar())
     461                return 1;
     462#endif
    295463//      printf("dlclose()... ");
    296464//      dlclose(handle);
Note: See TracChangeset for help on using the changeset viewer.