#14 WIN32 build

(default)
closed-accepted
1
2014-01-22
2004-06-01
Anonymous
No

I cannot get check to build on WIN32 using the
Microsoft compiler. The code I want to test is built from
a Cygwin prompt using the MS Visual Studio compiler
(cl), but I cannot get check to build in the same way.

I do not have enough experience to be able to edit
configure so that this works properly, but I can
(probably) set up a Visual Studio .NET project to get it
to build. Would you be interested in my project and
workspace files if I do manage to get it to build?

Ideally I would prefer to be able to use ./configure and
make, so if you can get this to work it would be much
appreciated. I am looking at using check as the
corporate unit test harness.

Alastair Growcott
BakBone Software

Alastair.Growcott (at) BakBone.co.uk

Discussion

  • Fredrik Hugosson

    • priority: 5 --> 1
     
  • Fredrik Hugosson

    • assigned_to: amalec --> hugo303
     
  • Chris Pickett

    Chris Pickett - 2006-11-19

    Logged In: YES
    user_id=715646
    Originator: NO

    There's a basic patch for WIN32 support here:

    http://opendarwin.org/pipermail/cvs-libfoundation-all/2005-March/000177.html

    Below is a verbatim copy of that page, in case the link goes bad.

    landonf 05/03/23 20:12:35

    Added: libFoundation/Tests README
    libFoundation/Tests/extras check-win32.diff
    Log:
    Add README and win32 patch for libcheck

    Revision Changes Path
    1.1 proj/libFoundation/Tests/README

    Index: README

    This directory contains the OpenDarwin libFoundation Unit Tests. These tests
    rely on the check unit test library.
    The check library is available from: http://check.sourceforge.net/

    In addition, the extras/ directory contains a diff that provides basic
    win32 support for check 0.9.2. Note that fork() and catching signals are
    not currently supported in this win32 port. check's own unit tests will
    fail due to changes in the patch:
    * Logging will fail, as this patch will change the logging output of
    the tests, including line numbers and the removal of some tests.
    * There are tests that call exit(1). This will cause abrupt
    termination of the entire test, as there is no fork().

    1.1 proj/libFoundation/Tests/extras/check-win32.diff

    Index: check-win32.diff

    diff -rwub check-0.9.2/src/check_log.c check-0.9.2.win32/src/check_log.c
    --- check-0.9.2/src/check_log.c Thu Nov 4 05:52:16 2004
    +++ check-0.9.2.win32/src/check_log.c Sat Mar 12 13:26:30 2005
    @@ -20,6 +20,10 @@

    #include "config.h"

    +#ifdef WIN32
    +#include <windows.h>
    +#endif
    +
    #include <stdlib.h>
    #include <stdio.h>
    #include <sys/time.h>
    @@ -205,6 +209,26 @@

    }

    +#ifdef WIN32
    +static int gettimeofday(struct timeval *tp, void *unused) {
    + SYSTEMTIME syst;
    + time_t tlocal;
    + struct tm tmlocal;
    + GetLocalTime(&syst);
    + tmlocal.tm_sec = syst.wSecond;
    + tmlocal.tm_min = syst.wMinute;
    + tmlocal.tm_hour = syst.wHour;
    + tmlocal.tm_mday = syst.wDay;
    + tmlocal.tm_mon = syst.wMonth - 1;
    + tmlocal.tm_year = syst.wYear - 1900;
    + tmlocal.tm_isdst = -1;
    + tlocal = mktime (&tmlocal); /* convert to UTC */
    + tp->tv_sec = tlocal;
    + tp->tv_usec = syst.wMilliseconds * 1000;
    + return 1;
    +}
    +#endif /* WIN32 */
    +
    void xml_lfun (SRunner *sr, FILE *file, enum print_output printmode,
    void *obj, enum cl_event evt)
    {
    @@ -218,7 +242,11 @@
    {
    now = emalloc(sizeof(struct tm));
    gettimeofday(&inittv, NULL);
    +#ifdef WIN32
    + now = localtime(&(inittv.tv_sec)); /* Uses thread-local storage on win32 */
    +#else
    localtime_r(&(inittv.tv_sec), now);
    +#endif
    }

    switch (evt) {
    diff -rwub check-0.9.2/src/check_msg.c check-0.9.2.win32/src/check_msg.c
    --- check-0.9.2/src/check_msg.c Thu Nov 4 05:52:16 2004
    +++ check-0.9.2.win32/src/check_msg.c Sat Mar 12 13:29:51 2005
    @@ -187,10 +187,14 @@
    {
    MsgKey key;

    +#ifndef WIN32
    if (cur_fork_status () == CK_FORK)
    key.key = getppid ();
    else
    key.key = getpid ();
    +#else
    + key.key = getpid();
    +#endif

    return key;
    }
    diff -rwub check-0.9.2/src/check_run.c check-0.9.2.win32/src/check_run.c
    --- check-0.9.2/src/check_run.c Tue Nov 9 07:34:25 2004
    +++ check-0.9.2.win32/src/check_run.c Sat Mar 12 12:22:37 2005
    @@ -22,7 +22,9 @@
    #include "config.h"

    #include <sys/types.h>
    +#ifndef WIN32
    #include <sys/wait.h>
    +#endif /* !WIN32 */
    #include <unistd.h>
    #include <stdlib.h>
    #include <stdio.h>
    @@ -63,29 +65,41 @@
    static void tcase_run_checked_teardown (TCase *tc);
    static void srunner_iterate_tcase_tfuns (SRunner *sr, TCase *tc);
    static void srunner_add_failure (SRunner *sr, TestResult *tf);
    +#ifndef WIN32
    static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tf);
    +#endif
    static TestResult *tcase_run_tfun_nofork (SRunner *sr, TCase *tc, TF *tf);
    +#ifndef WIN32
    static TestResult *receive_result_info_fork (const char *tcname,
    const char *tname,
    int status, int expected_signal);
    +#endif
    static TestResult *receive_result_info_nofork (const char *tcname,
    const char *tname);
    +#ifndef WIN32
    static void set_fork_info (TestResult *tr, int status, int expected_signal);
    +#endif
    static void set_nofork_info (TestResult *tr);
    +#ifndef WIN32
    static char *signal_msg (int sig);
    static char *signal_error_msg (int signal_received, int signal_expected);
    +#endif
    static char *pass_msg (void);
    +#ifndef WIN32
    static char *exit_msg (int exitstatus);
    static int waserror (int status, int expected_signal);
    +#endif

    #define MSG_LEN 100

    +#ifndef WIN32
    static pid_t current_test;

    static void sig_handler(int sig_nr)
    {
    kill(current_test, SIGKILL);
    }
    +#endif /* !WIN32 */

    static void srunner_run_init (SRunner *sr, enum print_output print_mode)
    {
    @@ -131,8 +145,10 @@

    void srunner_run_all (SRunner *sr, enum print_output print_mode)
    {
    +#ifndef WIN32
    struct sigaction old_action;
    struct sigaction new_action;
    +#endif /* WIN32 */

    if (sr == NULL)
    return;
    @@ -140,13 +156,17 @@
    eprintf("Bad print_mode argument to srunner_run_all: %d",
    __FILE__, __LINE__, print_mode);

    +#ifndef WIN32
    memset(&new_action, 0, sizeof new_action);
    new_action.sa_handler = sig_handler;
    sigaction(SIGALRM, &new_action, &old_action);
    +#endif /* !WIN32 */
    srunner_run_init (sr, print_mode);
    srunner_iterate_suites (sr, print_mode);
    srunner_run_end (sr, print_mode);
    +#ifndef WIN32
    sigaction(SIGALRM, &old_action, NULL);
    +#endif /* !WIN32 */
    }

    static void srunner_add_failure (SRunner *sr, TestResult *tr)
    @@ -174,7 +194,11 @@
    tfun = list_val (tfl);
    switch (srunner_fork_status(sr)) {
    case CK_FORK:
    +#ifdef WIN32
    + tr = tcase_run_tfun_nofork (sr, tc, tfun);
    +#else
    tr = tcase_run_tfun_fork (sr, tc, tfun);
    +#endif
    break;
    case CK_NOFORK:
    tr = tcase_run_tfun_nofork (sr, tc, tfun);
    @@ -295,6 +319,7 @@
    }
    }

    +#ifndef WIN32
    static TestResult *receive_result_info_fork (const char *tcname,
    const char *tname,
    int status, int expected_signal)
    @@ -311,6 +336,7 @@

    return tr;
    }
    +#endif

    static TestResult *receive_result_info_nofork (const char *tcname,
    const char *tname)
    @@ -327,6 +353,7 @@
    return tr;
    }

    +#ifndef WIN32
    static void set_fork_info (TestResult *tr, int status, int signal_expected)
    {
    int was_sig = WIFSIGNALED(status);
    @@ -367,6 +394,7 @@
    }
    }
    }
    +#endif /* !WIN32 */

    static void set_nofork_info (TestResult *tr)
    {
    @@ -392,7 +420,7 @@
    return tr;
    }

    -
    +#ifndef WIN32
    static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tfun)
    {
    pid_t pid;
    @@ -438,7 +466,9 @@
    signal, strsignal(signal));
    return msg;
    }
    +#endif /* !WIN32 */

    +#ifndef WIN32
    static char *exit_msg (int exitval)
    {
    char *msg = emalloc(MSG_LEN); /* free'd by caller */
    @@ -446,6 +476,7 @@
    "Early exit with return value %d", exitval);
    return msg;
    }
    +#endif /* !WIN32 */

    static char *pass_msg (void)
    {
    @@ -473,6 +504,7 @@
    sr->fstat = fstat;
    }

    +#ifndef WIN32
    static int waserror (int status, int signal_expected)
    {
    int was_sig = WIFSIGNALED (status);
    @@ -483,3 +515,4 @@
    return ((was_sig && (signal_received != signal_expected)) ||
    (was_exit && exit_status != 0));
    }
    +#endif /* WIN32 */
    Only in check-0.9.2.win32: stamp-h
    Only in check-0.9.2.win32/tests: Makefile
    diff -rwub check-0.9.2/tests/check_check_pack.c check-0.9.2.win32/tests/check_check_pack.c
    --- check-0.9.2/tests/check_check_pack.c Fri Apr 12 02:54:17 2002
    +++ check-0.9.2.win32/tests/check_check_pack.c Sat Mar 12 13:28:58 2005
    @@ -188,6 +188,7 @@
    }
    END_TEST

    +#ifndef WIN32
    START_TEST(test_ppack)
    {
    int filedes[2];
    @@ -370,6 +371,7 @@
    free (fmsg.msg);
    }
    END_TEST
    +#endif /* !WIN32 */

    Suite *make_pack_suite(void)
    {
    @@ -387,16 +389,20 @@
    tcase_add_test (tc_core, test_pack_loc);
    tcase_add_test (tc_core, test_pack_ctx);
    tcase_add_test (tc_core, test_pack_len);
    +#ifndef WIN32
    tcase_add_test (tc_core, test_ppack);
    tcase_add_test (tc_core, test_ppack_noctx);
    tcase_add_test (tc_core, test_ppack_onlyctx);
    tcase_add_test (tc_core, test_ppack_multictx);
    tcase_add_test (tc_core, test_ppack_nofail);
    +#endif /* !WIN32 */
    suite_add_tcase (s, tc_limit);
    tcase_add_test (tc_limit, test_pack_ctx_limit);
    tcase_add_test (tc_limit, test_pack_fail_limit);
    tcase_add_test (tc_limit, test_pack_loc_limit);
    +#ifndef WIN32
    tcase_add_test (tc_limit, test_ppack_big);
    +#endif /* !WIN32 */

    return s;
    }

     
  • Branden Archer

    Branden Archer - 2014-01-22

    As of Check 0.9.12 Visual Studios is officially supported. If you find any issues with specific versions of Visual Studios, or if you experience any trouble, please let us know.

     
  • Branden Archer

    Branden Archer - 2014-01-22
    • status: open --> closed-fixed
     
  • Branden Archer

    Branden Archer - 2014-01-22
    • status: closed-fixed --> closed-accepted
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks