glib: modular test fixtures?
Maybe I've just been up too late and am not thinking straight, but I suppose it doesn't hurt to ask... is there some way to use the Glib testing framework so as to have modular fixtures that could be combined or separated on a per-test basis? I'm staring at the API, but not seeing it. What I mean is: Say, I have test function A, which needs a fixture providing an open FILE stream, and test function B, which needs a fixture providing an character buffer, and test function C, which needs both. Ideally, I would be able to simply write a "file stream" fixture, and a "character buffer" fixture, and then somehow use both in test function C. Obviously, one approach would be to write a single fixture which provides both the FILE stream and the character buffer, and pass that to all functions. But then it starts to get complicated if, say, I add a test function D, which needs the same FILE stream, but a character buffer of a different size. Add enough functions, and I end up with a bunch of massive, clumsy fixtures (and fixture functions) that repeat a lot of the same code, yet differ slightly from each other. -- frigidcode.com indicium.us ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Help with a multi-threaded application. Spot a crash.
Hello, I have a multi-threaded application that filters data practically while user types text in an entry-field. But this applications regularly crashes. This surprises me because I have done similar code in another occacion and language. This particular Gtk code is from an open source app. So Would you help me to spot this annoying "segmentation fault" so I could move on. This seq-fault happens every time. $ ./test2 Came here 0 Came here 0 Came here 0 Came here 0 Came here 0 Came here 0 Came here 0 Came here 0 Came here 0 Came here 0 Came here 1 Came here 1 Segmentation fault Here is a complete test-code which I modelled after the actual application. It will show the crash. http://www.futuredesktop.org/tmp/test2.c Compile it for Gtk2: gcc -Wall test2.c -o test2 $(pkg-config --cflags --libs gtk+-2.0 gdk-2.0 gthread-2.0) Or for Gtk3: gcc -Wall test2.c -o test2 $(pkg-config --cflags --libs gtk+-3.0 gdk-3.0 gthread-2.0) And run: ./test2 TIA! All comments are welcomed. Kindly osmo antero http://www.futuredesktop.org ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Help with a multi-threaded application. Spot a crash.
Oh, I forgot to mension. Compile and start the test2 app and then press the "Test..." button at the top. It will fire 10 threads. Each of them creates own a GRegex object. Then the crash. // Osmo Antero ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Help with a multi-threaded application. Spot a crash.
On Wed, May 30, 2012 at 08:30:40PM +0100, Osmo Antero wrote: > I have a multi-threaded application that filters data practically > while user types text in an entry-field. But this applications > regularly crashes. GRegex is not a GObject, it's just POD. So if (G_IS_OBJECT(search->regex)) will surely attempt to read some bogus memory location and crash. I cannot see why such code is there at all but anyway set search->regex to NULL if it does not exist and then just use if (search->regex) if necessary. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Help with a multi-threaded application. Spot a crash.
Hello, Thank you very much. I actually commented out pretty much everything but the G_IS_OBJECT(). I took it granted that GRegex was a gobject. Now learned that it's a POD, Perl Object. The actual code has also a LockedCounter (mutex controlled) object that feeds each thread with a unique sequence number. Only the thread with highest sequence number can tick and change the GUI, others will simply die away. Now the project can progress. Obrigado Osmo Antero On Wed, May 30, 2012 at 9:02 PM, David Nečas wrote: > On Wed, May 30, 2012 at 08:30:40PM +0100, Osmo Antero wrote: >> I have a multi-threaded application that filters data practically >> while user types text in an entry-field. But this applications >> regularly crashes. > > GRegex is not a GObject, it's just POD. So > > if (G_IS_OBJECT(search->regex)) > > will surely attempt to read some bogus memory location and crash. > I cannot see why such code is there at all but anyway set search->regex > to NULL if it does not exist and then just use > > if (search->regex) > > if necessary. > > Yeti > -- // moma http://www.futuredesktop.org ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list