Samstag, März 24, 2007

Wine Testing (Don't Forget to Spit)

I've had to do some job-related learning of the Windows API lately, and while my experiences in that could fill a canyon, it has also lead me to rekindle a long-dead curiosity in the WINE Project. I began my studying by leaving the safe, loving arms of FreeBSD for an XP Pro box with a free edition of Visual C++ Express. I had heard plenty of complaints in the past about the WinAPI, but put them down to lazy Windows programmers not wanting to get their hands dirty. The truth is, the Windows API deserves complainers. It's ugly, illegible, and confusing. If your idea of GUI programming is a clean, object-oriented Qt interface, do yourself a favour and never take a look at a WNDCLASS. The fact that it's called a class is about as close as it comes to object-orientation.

Perhaps I'm being too harsh. After all, the API of Windows specifies not only GUI components, but everything about the operating system. If the FreeBSD kernel, XServer, and KDE were all combined into one disgusting, disorganised, and nonsensical blob, it would be just as painful to program. Fortunately, nobody in the *nix world is insane enough to try something like that. They also avoid wherever possible giving data types confusing and unnecessary names in all-uppercase letters. What's an HINSTANCE? It's a handle. Theoretically naming shit like this is supposed to save you time and prevent errors. It's not a 4-byte int, it's a 4-byte int redefined as a handle instance. Therefore it must be safer. Right. You know what? If you're using functions without reading the API documentation, your code probably isn't preventing any errors or saving any time anyway. And the time it takes to look in that function documentation and see what that integer represents takes all of 1 second.

Nevertheless, I progressed. Despite the fact that Visual C++ Express Edition totally lacks MFC support, which makes it pretty much useless for maintaining existing programs of any decent size that aren't crazy enough to use the Windows API directly, it was all right. But I kept asking myself, "Do I have to use this?" Every hour I spent in XP wondering if the computer would become nonresponsive at any moment or trying to calculate how many emails my undoubtedly bot-infected PC was spewing into the tubes, I could've been doing something cool and interesting in my beloved 6.2-RELEASE baby. After a total of 8 hours using Visual C++, I just said "Fuck it, there has to be a better way," and went back to the BSD box. I installed WINE, which I hadn't done since perhaps late 2005 when I toyed with it for awhile, and discovered the Winelib tools.

I'm not naive. At least not in this matter. I realise WINE isn't a perfect platform for Windows API programming; in fact, I found many a Google site shouting at curious inquirers not to try learning win32 in a WINE environment. You'd have to be crazy, they said. Well, perhaps I am...Perhaps I am.

If you're unfamiliar with the Windows API, a good starting point on the Internet is this site: http://www.relisoft.com/win32/index.htm. It contains a few tutorials that are easy enough to follow. Where they get interesting, for me at least, is in their usage as conformance tests for WINE and Winelib's toolset. So without much further ado, I begin with Test #1 (on the tutorial site this program is called "Winnie"). What follows is basically a lazy and shameless copy and paste of the README I wrote for that archive:


This is a "book testing" approach to Wine conformance using a
website rather than a standard book. I've had to modify the
files slightly, but nothing syntactic. The proper way to test
whether this works under WINE is to perform the following commands
in the directory of the source:

winemaker --lower-uppercase .
make

If it compiles, you know at least your WINE installation (0.9.33)
can get as far as mine. Now copy the resulting output (for me
this file is called winnie.exe.so) to somewhere in the WINE
base directory and call it. For example, on my system it would
look like this:

cp winnie.exe.so ~/.wine/drive_c/winnie.exe
wine "c:\winnie"

If all went well, you should now see a boring white window with
a friendly titlebar.


The source for this test can be found here: http://drlight.multics.org/winetests/winnie_winetest.tar.gz

And here's a screenshot of this exciting, do-nothing application!

Here's a screenshot of this exciting, do-nothing application!

8 Comments:

At 6:46 AM, Blogger Friendy said...

Dieser Post wurde vom Autoren entfernt.

 
At 6:48 AM, Blogger Friendy said...

When I saw the name of that article I thought you were going to reveal your results of tasting various Austrian wines. :)

 
At 6:59 AM, Blogger Friendy said...

Dieser Post wurde vom Autoren entfernt.

 
At 7:00 AM, Blogger Friendy said...

Dieser Post wurde vom Autoren entfernt.

 
At 7:07 AM, Blogger Friendy said...

Btw, I'm now reading theForger's Win32 API Tutorial. Do you know it? (Actually I wanted to include an url in the post but the blogger screws it up whenever I publish it, though in preview it looks OK, I guess it's a bug)

 
At 11:01 PM, Blogger Whoa! Mozart's Ghost! said...

Yeah, don't trust it. I've had to go back and edit 3 or 4 comments because the Preview was totally different from the actual published post.

 
At 11:52 PM, Blogger Friendy said...

I think it wasn't so in the previous version of the blogspot. Another thing that I don't like here is that it doesn't show the date when a comment was published. If I'm not mistaken in the previous version it was shown only in preview (why on earth? it's mostly useless there) but now it's not there either. I wonder if they are going to fix it eventually (actually I hoped they would fix it in the present version).

 
At 5:43 AM, Blogger Pam said...

It's true I totally perved out and creeped around online to find you. Your old addresses didn't work. Where in the fuck have you been?
I'm so stalking this site from now on...

 

Kommentar veröffentlichen

<< Home