• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Target setup for unit testing (using cppunit)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Target setup for unit testing (using cppunit)


  • Subject: Re: Target setup for unit testing (using cppunit)
  • From: Stefan van den Oord <email@hidden>
  • Date: Mon, 28 Nov 2005 11:24:57 +0100

Just another note for others who may be reading this thread:

Instead of linking my testlib using '-lTestLib', I now use dlopen() to
load the library at run-time, when the --test argument is specified. I
pass the name of the dylib to load as a command line paramater,
because on Linux it is different (.so instead of .dylib).

Code snippit:

/* Type definition of the test function that is called */
typedef int (*mainTest)(int argc, char *argv[]);

/* Main function */
int main (int argc, char *argv[])
{
	/* If the first argument is "--test" */
	if (argc >= 2 && strcmp(argv[1],"--test")==0)
	{
		/* The lib we'll load is the second command line argument */
		if (argc < 3)
		{
			printf("Error: supply test dynamic library as second parameter on
command line\n");
			return -1;
		}
		const char *lib = argv[2];

		/* Open the library */
		void *handle = NULL;
		handle = dlopen(lib, RTLD_LAZY);
		if (handle == NULL)
		{
			printf("Could not dlopen() library: %s\n", dlerror());
			return -2;
		}

		/* Load the mainTest symbol */
		void* mainTestFunc = dlsym(handle, "mainTest");
		if (mainTestFunc == NULL) {
			printf("Symbol %s not found!\n", "mainTest");
		}

		/* Run the test */
		return ((mainTest)mainTestFunc)(argc, argv);
	}
}
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Target setup for unit testing (using cppunit) (From: Chris Hanson <email@hidden>)
 >Re: Target setup for unit testing (using cppunit) (From: Stefan van den Oord <email@hidden>)

  • Prev by Date: Re: Target setup for unit testing (using cppunit)
  • Next by Date: Re: Stepping over inline functions
  • Previous by thread: Re: Target setup for unit testing (using cppunit)
  • Next by thread: Xcode 2.2: /usr/bin/ld: Undefined symbols: __Unwind_Resume
  • Index(es):
    • Date
    • Thread