How to do tests

Since quite some people have asked how to do tests for Swfdec, here’s a short Howto. You need:

  • Ming for creating the test files. You probably want a 0.4.0 beta, and not the packages found in distros.
  • A Flash debug player. I use the Windows debug player via wine.

You need to configure the debug player to provide debug output. Create the file ~/.wine/dosdevices/c:/windows/profiles/$USERNAME/mm.cfg and have its contents be (you might need Windows-style CRLF line feeds, not sure):

ErrorReportingEnable=1
TraceOutputFileEnable=1

Now for every Flash file you run with the debug player, a text file will be created that contains trace output and other interesting warnings. It will be at
~/.wine/dosdevices/c:/windows/profiles/$USERNAME/Application Data/Macromedia/Flash Player/Logs/flashlog.txt. I have softlinked that file to flash.log.

Now we need to write a test. Have a look at the test/trace/ subdirectory and the included *.as and *.c files to learn about those tests. The directory also contains a README file, that might give some hints. I’ll focus on the as files here. So let’s assume, we really want to know if NaN == NaN, we’ll write a small test file nan.as:

// makeswf -v 7 -s 200x150 -r 1 -o nan.swf nan.as

// Add a nice description here, so we have an idea what this test is about when it fails.
trace ("Check if NaN == NaN");
trace (NaN == NaN);

// This quits Adobe's Flash player, so we don't have to close it automatically.
loadMovie ("FSCommand:quit", "");

Now compile and run it:

makeswf -v 7 -s 200x150 -r 1 -o nan.swf nan.as && \
wine sa_flashplayer_9_debug.exe nan.swf && \
cp flash.log nan.swf.trace && \
perl -pi -e 's/\\r\\n$/\\n/;' nan.swf.trace;

As you can see, the debug output was copied to the right filename and line feeds were adapted already. Now just copy the files into Swfdec’s test/trace directory and see if Swfdec handles it correctly by running ./trace nan.swf. If it doesn’t, it’ll print the diff between the trace file and the output of Swfdec. And you can go looking at the code to determine who’s at fault. Or write the next test. :)

2 comments ↓

#1 shirish on 06.16.07 at 10:00

hi otte,
nothing to do with the post, just a suggestion, when you are doing the syndication at http://www.advogato.org/person/company/ don’t just give swfblag, if its possible make it gnome swfblag, so people like me can find it easy to come here rather than go to the next page & find the shift to gnome blogs entry. Just a thought, dunno what u think.

#2 shirish on 06.16.07 at 10:03

oh and another thing, when u say #swfdec please mention that its irc.freenode.net (the server) , I was unsuccessfully trying irc.gimp.org due to you being with GNOMe.