<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-17885055</id><updated>2012-01-29T16:13:02.557-05:00</updated><category term='books'/><category term='boost'/><category term='service'/><category term='hfs'/><category term='dublin'/><category term='array'/><category term='cocoa'/><category term='multiboot'/><category term='monotone'/><category term='monitors'/><category term='git'/><category term='haskell'/><category term='journal'/><category term='locales'/><category term='performance'/><category term='freebsd'/><category term='vnd'/><category term='review'/><category term='c++'/><category term='soc'/><category term='msdos'/><category term='rant'/><category term='colloquy'/><category term='xml'/><category term='sport'/><category term='ps3'/><category term='lost'/><category term='camera'/><category term='ntfs'/><category term='x11'/><category term='yellowdog'/><category term='announce'/><category term='networking'/><category term='c'/><category term='pfc'/><category term='sf'/><category term='parallels'/><category term='housing'/><category term='report'/><category term='portability'/><category term='desktop'/><category term='mbp'/><category term='software'/><category term='mac'/><category term='pkgsrccon'/><category term='optimization'/><category term='tmpfs'/><category term='m4'/><category term='race'/><category term='release'/><category term='ubuntu'/><category term='pkgsrc'/><category term='testing'/><category term='nyc'/><category term='volumes'/><category term='vcs'/><category term='nvidia'/><category term='exif'/><category term='compiler'/><category term='google'/><category term='cooking'/><category term='autoconf'/><category term='virtualization'/><category term='atf'/><category term='packaging'/><category term='analyzer'/><category term='fuse'/><category term='smart'/><category term='dd-wrt'/><category term='macbookpro'/><category term='macosx'/><category term='perl'/><category term='fedora'/><category term='conference'/><category term='lua'/><category term='photos'/><category term='assembly'/><category term='gnome'/><category term='benq'/><category term='phd'/><category term='powerpc'/><category term='python'/><category term='cables'/><category term='windows'/><category term='laptops'/><category term='pin'/><category term='compiz'/><category term='crawler'/><category term='netbsd'/><category term='update'/><category term='hardware'/><category term='linux'/><category term='router'/><category term='hibernate'/><category term='sunos'/><category term='oss'/><category term='cvs'/><category term='cogito'/><category term='research'/><category term='kyua'/><category term='fragmentation'/><category term='vacation'/><category term='processor'/><category term='process'/><category term='sockets'/><category term='dvcs'/><category term='videos'/><category term='teasert'/><category term='games'/><category term='multicore'/><category term='blog'/><category term='cell'/><category term='kde'/><category term='linksys'/><category term='systemtap'/><category term='source'/><category term='running'/><category term='unix'/><category term='twitter'/><category term='puntacana'/><category term='credentials'/><category term='parallelism'/><category term='lutok'/><category term='etcutils'/><category term='keyboards'/><category term='article'/><category term='series'/><category term='bloat'/><category term='fusion'/><category term='icb'/><title type='text'>The Julipedia: Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.julipedia.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default?start-index=101&amp;max-results=100'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>580</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-17885055.post-283894938669140420</id><published>2012-01-29T16:12:00.003-05:00</published><updated>2012-01-29T16:13:02.570-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lutok'/><category scheme='http://www.blogger.com/atom/ns#' term='release'/><title type='text'>Lutok 0.1 available</title><content type='html'>A few months ago, I &lt;a href="http://blog.julipedia.org/2011/09/introducing-lutok-lightweight-c-api-for.html"&gt;introduced the Lutok project&lt;/a&gt;,&amp;nbsp;a simple C++ API for Lua. To recap: the major goal of this API, which does not mimic the Lua C API bit by bit, is to enforce correct coding practices on the client side. This is done by (ab)using the RAII programming pattern to automatically free resources when not needed and to ensure that the Lua stack is correctly managed. The library also adheres to common C++ programming idioms and exposes exceptions for error management and uses the pimpl idiom to completely hide the Lua C API from clients of Lutok (unless you use the &lt;tt&gt;c_gate&lt;/tt&gt; backdoor!).&lt;br /&gt;&lt;br /&gt;Today, I am pleased to announce that the first formal release of Lutok, obviously named 0.1, is available for download! You can obtain this release by visiting the &lt;a href="http://code.google.com/p/lutok/downloads/detail?name=lutok-0.1.tar.gz"&gt;lutok-0.1.tar.gz download page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Also, in preparation for this release, I have spent the weekend writing &lt;a href="http://code.google.com/p/lutok/wiki/Examples"&gt;some little example programs&lt;/a&gt; to demonstrate the usage of Lutok, and also some&amp;nbsp;&lt;a href="http://code.google.com/p/lutok/wiki/Installation"&gt;installation instructions&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Hope you find this release useful and please do send me any comments you may have!&lt;br /&gt;&lt;br /&gt;Hint: Yes, releasing Lutok 0.1 was a prerequisite for Kyua 0.3. So stay tuned ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-283894938669140420?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/283894938669140420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=283894938669140420' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/283894938669140420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/283894938669140420'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2012/01/lutok-01-available.html' title='Lutok 0.1 available'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2326868603928918712</id><published>2012-01-23T10:28:00.002-05:00</published><updated>2012-01-23T10:28:21.385-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.netbsd.org/~jmmv/atf/news.html#20120116-atf-0-15-released"&gt;Released ATF 0.15&lt;/a&gt; and imported it into NetBSD.&lt;/li&gt;&lt;li&gt;Added support for integer/float printf-like modifiers to the &lt;tt&gt;utils::format&lt;/tt&gt; module. These will be required to beautify size and time quantities in the reports and error messages.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;I spent way more time than I wanted on this. At first, I attempted to use &lt;tt&gt;std::snprintf&lt;/tt&gt; to parse and process the format modifiers for integers and floats so that I could avoid implementing a custom parser for them. While this sounds like a cool idea (yay, code reuse!), it resulted in a ugly, nasty and horrible mess. In the end, I just ended up implementing custom parsing of the formatters, which was way easier and "good enough" for Kyua's needs.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Started work on backporting ATF's new &lt;tt&gt;require.memory&lt;/tt&gt; property into Kyua. This needs having a way to parse and format byte quantities in user-friendly forms (e.g. 1k, 2m, etc.)... hence the previous work on &lt;tt&gt;utils::format&lt;/tt&gt;!&lt;/li&gt;&lt;li&gt;Set up a &lt;a href="https://plus.google.com/b/109170076014992185386/"&gt;Google+ Page for Kyua&lt;/a&gt;. I have no idea what to use it for yet. Maybe the status reports should go in there. Ideas?&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2326868603928918712?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2326868603928918712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2326868603928918712' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2326868603928918712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2326868603928918712'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2012/01/kyua-weekly-status-report_23.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4383268139030266213</id><published>2012-01-15T22:21:00.003-05:00</published><updated>2012-01-15T22:21:42.830-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Finally some progress!&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Backported the &lt;tt&gt;require.memory&lt;/tt&gt; changes in NetBSD to the ATF upstream code, and extended them to support OS X as well.&lt;/li&gt;&lt;li&gt;Backported local pkgsrc patches to ATF into the upstream code.&lt;/li&gt;&lt;li&gt;Started to prepare ATF 0.15 by doing test runs of NetBSD/i386 and NetBSD/amd64 and by building the code in various Linux distributions. Several build bugs fixed along the way.&lt;/li&gt;&lt;li&gt;Spent a long while trying to figure out how the Fedora package maintainer procedure has changed since 3 years ago to create packages for ATF, Lutok and Kyua. Not very successful yet unfortunately.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Nothing on the Kyua front, but getting a new release of ATF out of the door has higher priority now!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4383268139030266213?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4383268139030266213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4383268139030266213' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4383268139030266213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4383268139030266213'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2012/01/kyua-weekly-status-report_15.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-3855575707225556807</id><published>2012-01-10T22:44:00.001-05:00</published><updated>2012-01-10T22:44:08.985-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>It's that time of the week again (although delayed by over a day). Unfortunately, no progress either during past week. Being on semi-vacations doesn't leave much "free time"... However, I traveled back home yesterday and getting back to my daily routine should give some spare time!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-3855575707225556807?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/3855575707225556807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=3855575707225556807' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3855575707225556807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3855575707225556807'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2012/01/kyua-weekly-status-report_10.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6092010260159605891</id><published>2012-01-03T05:25:00.003-05:00</published><updated>2012-01-03T05:25:31.160-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Happy new year!&lt;br /&gt;&lt;br /&gt;No activity past week as I was completely away from the computer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6092010260159605891?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6092010260159605891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=6092010260159605891' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6092010260159605891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6092010260159605891'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2012/01/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/05472505959624132834</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-9196312908393344096</id><published>2011-12-26T06:38:00.000-05:00</published><updated>2011-12-26T06:38:04.983-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>The post title should mention ATF instead of Kyua... but I'm keeping the usual one for consistency:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Integrated timestamps into the XML and HTML reports generated by &lt;tt&gt;atf-report&lt;/tt&gt;. These should soon show up in the continuous tests of NetBSD.&lt;/li&gt;&lt;li&gt;Work on integrating the use of POSIX timers into &lt;tt&gt;atf-run&lt;/tt&gt; after Christos Zoulas performed these changes in the NetBSD tree. The result is quite awful because I need to keep compatibility with systems that do not provide the "new" interface...&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-9196312908393344096?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/9196312908393344096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=9196312908393344096' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/9196312908393344096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/9196312908393344096'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/12/kyua-weekly-status-report_26.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-113774404018064899</id><published>2011-12-19T10:35:00.000-05:00</published><updated>2011-12-19T10:35:39.669-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Unfortunately, not much activity this week due to travel reasons. Anyway, some work went in:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Preliminary code to generate HTML reports from &lt;tt&gt;kyua report&lt;/tt&gt;. This is easy peasy but boring. The current code was written as a proof of concept and is awful, hence why it was not committed. I'm now working in cleaning it up.&lt;/li&gt;&lt;li&gt;Backported test program and test case timestamping into ATF based on a patch from Paul Goyette. This is a very useful feature to have, and it will have to be added to Kyua later. (It has always been planned to be added, but have not had the time yet.)&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-113774404018064899?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/113774404018064899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=113774404018064899' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/113774404018064899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/113774404018064899'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/12/kyua-weekly-status-report_19.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7946776269603782071</id><published>2011-12-11T22:16:00.001-05:00</published><updated>2011-12-11T22:30:01.076-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Some significant improvements this week:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Finally submitted the code to store and load full test case definitions. This is quite tricky (and currently very, very ugly) but it works and it will allow the reports to include all kinds of information from the test cases.&lt;/li&gt;&lt;li&gt;Removed the &lt;tt&gt;Atffile&lt;/tt&gt;s from the tree; yay! For a long time, I had been using &lt;tt&gt;atf-run&lt;/tt&gt; to run broken tests because &lt;tt&gt;atf-run&lt;/tt&gt; allowed me to watch the output of the test case being debugged. However, this has been unnecessary since the &lt;a href="http://blog.julipedia.org/2011/08/kyua-weekly-status-report_22.html"&gt;introduction of the &lt;tt&gt;debug&lt;/tt&gt; command in late August&lt;/a&gt;. I now feel confident that these files can go. (And &lt;tt&gt;debug&lt;/tt&gt; is much more powerful than &lt;tt&gt;atf-run&lt;/tt&gt; because you can target a single test case instead of a whole test program.)&lt;/li&gt;&lt;li&gt;Some crazy work attempting to hide the name of SQLite types from the &lt;tt&gt;sqlite::statement&lt;/tt&gt; interface. I've been only able to do so somewhat decently for &lt;tt&gt;bind&lt;/tt&gt;, but all my attempts at doing the same with &lt;tt&gt;column&lt;/tt&gt; result in horrible code so far. So no, such changes have not been submitted.&lt;/li&gt;&lt;li&gt;As of a few minutes ago, &lt;tt&gt;kyua test&lt;/tt&gt; now records the output of the test cases (stdout and stderr) into the database. These will be invaluable for debugging of test cases, particularly when the reports are posted online.&lt;/li&gt;&lt;li&gt;Some preliminary work at implementing HTML reports. This, however, has not received much progress due to the previous item requiring completion.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I'm quite excited at this point. HTML reports are a few weeks away &lt;i&gt;at most&lt;/i&gt;. Once that happens, it will be time to start considering replacing the &lt;tt&gt;atf-run&lt;/tt&gt; / &lt;tt&gt;atf-report&lt;/tt&gt; duo for good, particularly within NetBSD. This will certainly not be easy... but all the work that has gone into Kyua so far has this sole goal!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7946776269603782071?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7946776269603782071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7946776269603782071' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7946776269603782071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7946776269603782071'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/12/kyua-weekly-status-report_11.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-3760015699059977369</id><published>2011-12-05T19:20:00.001-05:00</published><updated>2011-12-05T19:28:06.045-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Some more work towards allowing storing and loading of full test case definitions (which in turn will allow us to provide detailed HTML reports). I have local changes that do this, but they are gated by the lack of some additional tests and probably some optimizations, because they slow down &lt;tt&gt;kyua report&lt;/tt&gt; significantly. Regarding commits, I have only submitted some related cleanup-changes.&lt;/li&gt;&lt;li&gt;I got distracted by invalid Doxygen comments and traced down why they were not being correctly validated (which is the whole point of running Doxygen during the build). It turns out I had to enable some extra &lt;tt&gt;EXTRACT_*&lt;/tt&gt; settings in the &lt;tt&gt;Doxyfile&lt;/tt&gt;. After doing so, I realized there are many, many documentation problems in the code... and I have been fixing them since. It's a tough operation, but I'm more than half-way through already. To give you an idea, the current diffstat shows about 650 new comment lines (!).&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-3760015699059977369?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/3760015699059977369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=3760015699059977369' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3760015699059977369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3760015699059977369'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/12/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8378862959071731158</id><published>2011-11-28T10:06:00.001-05:00</published><updated>2011-11-28T10:11:43.827-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>My goal for this past week was to change the database layer to be able to store full definitions of the test cases, and to later be able to load these while scanning an action. This is to allow the &lt;tt&gt;report&lt;/tt&gt; command to provide all kinds of information about the executed tests, not just their names and their results. However, adding this functionality has proven to be more complex than I wished because the current types to represent test programs and test cases are kinda broken: that the abstractions chosen a while ago do not seem to be appropriate, and this is complicating further changes.&lt;br /&gt;&lt;br /&gt;Due to this, I ended up doing some cleanups. First, I reimplemented the way in which test programs that fail to list their test cases are represented. And second, I got rid of the useless &lt;tt&gt;test_case_id&lt;/tt&gt; class, which exposed even further problems in the data types that represent test cases.&lt;br /&gt;&lt;br /&gt;It's now time to sit and think if the current representations of test programs and test cases make sense and, if not, how to better redo them. Not going to be easy, but I hope to have some time for this cleanup during this upcoming week.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8378862959071731158?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8378862959071731158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8378862959071731158' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8378862959071731158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8378862959071731158'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/11/kyua-weekly-status-report_28.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-245230397741999971</id><published>2011-11-20T22:19:00.001-05:00</published><updated>2011-11-20T22:29:22.458-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>I only have one thing to report this week, but oh boy it's big: &lt;b&gt;the &lt;tt&gt;report&lt;/tt&gt; command finally reports the results of a run of a test suite!&lt;/b&gt; Yes, you heard well: Kyua is, finally, able to keep a record of all the previous executions of test suites and allows you to extract reports of any of them a posteriori.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;At the moment, the report is just some disorganized plain-text. &amp;nbsp;For example:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre&gt;$ kyua test&lt;/pre&gt;&lt;pre&gt;[... wait for the tests to run ...]&lt;/pre&gt;&lt;pre&gt;Committed action 82&lt;/pre&gt;&lt;pre&gt;$&amp;nbsp;kyua report&lt;br /&gt;===&amp;gt; Skipped tests&lt;br /&gt;[... too long to show ...]&lt;br /&gt;===&amp;gt; Expected failures&lt;br /&gt;integration/cmd_report_test:output__console__change_file &amp;nbsp;-&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; expected_failure: --output not implemented yet:&lt;br /&gt;&amp;nbsp; &amp;nbsp; atf-check failed; see the output of the test for details&lt;br /&gt;===&amp;gt; Failed tests&lt;br /&gt;store/transaction_test:put_test_case__ok &amp;nbsp;-&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; failed: Line 663: stmt.step() not met&lt;br /&gt;===&amp;gt; Summary&lt;br /&gt;Action: 82&lt;br /&gt;Test cases: 934 total, 15 skipped, 1 expected failures,&lt;/pre&gt;&lt;pre&gt;0 broken, 1 failed&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;I'm now working on changing the database schema to be able to really store all the data about test cases, because at the moment I'm only storing their names. Once all the original data is stored, the &lt;tt&gt;report&lt;/tt&gt; command will have lots more information to work with, and then will be the time to start improving the format of the reports. As mentioned earlier, having interactive HTML dashboards is high in the priority list, and a very important goal of Kyua altogether.&lt;br /&gt;&lt;br /&gt;Stay tuned :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-245230397741999971?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/245230397741999971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=245230397741999971' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/245230397741999971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/245230397741999971'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/11/kyua-weekly-status-report_20.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2140157323321450898</id><published>2011-11-14T11:21:00.001-05:00</published><updated>2011-11-14T11:28:22.656-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Kyua has finally gained a &lt;tt&gt;report&lt;/tt&gt; subcommand, aimed at processing the output data of an action (stored in the database) and generating a user-friendly report in a variety of formats. This is still extremely incomplete, so don't get your hopes too high yet ;-) The current version of the &lt;tt&gt;report&lt;/tt&gt; command takes an action and all it does is dump its runtime context (run directory, environment variables, etc.). Consider it just a proof of concept.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have now started work on loading the data of test case results for a particular action, and once that is done, the &lt;tt&gt;report&lt;/tt&gt; command will start yielding really useful data: i.e. it will actually tell you what happened during a particular execution of a test suite. The way I'm approaching the work these days is by building the skeleton code to implement the basic functionality first (which actually involves writing a lot of nasty code), with the goal of adding missing pieces later bit by bit.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For example, at this moment I'm only targeting text-based outputs with a limited set of data. However, when that is done, adding extra data or different formats will be relatively easy. Generating HTML dashboards (without going through XML, as was the case of &lt;tt&gt;atf-report&lt;/tt&gt;!) is definitely highly prioritized.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;By the way: I just realized it has already been one year since Kyua saw life. Wow, time flies. And only now we are approaching a point where killing the &lt;tt&gt;atf-run&lt;/tt&gt; / &lt;tt&gt;atf-report&lt;/tt&gt; pair is doable. I'm excited.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2140157323321450898?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2140157323321450898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2140157323321450898' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2140157323321450898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2140157323321450898'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/11/kyua-weekly-status-report_14.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5051367421950896129</id><published>2011-11-07T10:04:00.001-05:00</published><updated>2011-11-07T10:04:08.637-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Many things have happened this week, but they can all be summarized in one single sentence: &lt;tt&gt;&lt;b&gt;kyua test&lt;/b&gt;&lt;/tt&gt;&lt;b&gt; now records the results of the execution of a test suite into the SQLite database&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;"Why is this important?", you ask. Well, that's a good question. Recording test results opens the gate to many long-awaited features that should be coming soon, such as the ability to inspect the history of a particular test, to query all available data of a test result and/or to generate a dashboard of test results. It's interesting to realize that &lt;i&gt;most of these features are just one SQL query away&lt;/i&gt;. If you install Kyua, you can already run a few tests and then use &lt;tt&gt;kyua db-exec&lt;/tt&gt; to issue arbitrary SQL queries against the database; the schema (see &lt;tt&gt;store/schema.sql&lt;/tt&gt;) might look a bit convoluted, but a bunch of &lt;tt&gt;NATURAL JOIN&lt;/tt&gt;s will yield the desired output.&lt;br /&gt;&lt;br /&gt;The feature requests that have the highest priority at this point are the ability to generate a report of the last tests run both as a text file and as an HTML dashboard, because having these features means we can finally kill the &lt;tt&gt;atf-run&lt;/tt&gt; and &lt;tt&gt;atf-report&lt;/tt&gt; pair. At this point I'm, once again, "stuck" while figuring out how to best organize the code to make all these things possible while still keeping a nice separation across the existing layers (&lt;tt&gt;cli&lt;/tt&gt;, &lt;tt&gt;engine&lt;/tt&gt; and &lt;tt&gt;store&lt;/tt&gt;)... all without introducing much unnecessary complexity. But exciting times lie ahead!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5051367421950896129?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5051367421950896129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5051367421950896129' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5051367421950896129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5051367421950896129'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/11/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5304169474623962697</id><published>2011-10-31T10:50:00.004-04:00</published><updated>2011-10-31T10:50:50.923-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Submitted a placeholder implementation of the new persistence layer (&lt;tt&gt;store&lt;/tt&gt; top-level directory). This only supports opening a database and ensuring its metadata is valid. &lt;a href="http://code.google.com/p/kyua/source/detail?r=253"&gt;See r253&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Added a &lt;tt&gt;db-exec&lt;/tt&gt; CLI command to execute arbitrary SQL commands onto the database. This is handy during development and testing, but may also help users to extract information out of the database in those cases where the CLI does not cover their needs just yet. &lt;a href="http://code.google.com/p/kyua/source/detail?r=255"&gt;See r255&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Miscellaneous fixes and improvements to &lt;tt&gt;utils::env&lt;/tt&gt; and &lt;tt&gt;utils::sqlite&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;Preliminary code to support putting objects (like actions and contexts) into the database. I've been thinking about this for a while and finally came up with a design that completely decouples the persistence needs from the higher-level classes in the &lt;tt&gt;engine&lt;/tt&gt; layer. I haven't submitted the code yet though, as it lacks tests. (Still thinking how to write the loading of objects though.)&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5304169474623962697?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5304169474623962697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5304169474623962697' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5304169474623962697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5304169474623962697'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/10/kyua-weekly-status-report_31.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-402139290656767976</id><published>2011-10-23T22:12:00.001-04:00</published><updated>2011-10-23T22:12:25.845-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Moved all the logic code of the "debug", "list" and "test" commands from the CLI layer to the engine layer.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Up until now, the CLI modules implementing these commands contained all the logic to load Kyuafiles and iterating over them to find matching tests and applying the desired operation to them. This kind of code belongs in "driver" modules (aka controllers) of the engine layer, because there is nothing UI-related in them.&lt;/li&gt;&lt;li&gt;After this refactoring, the code left in the CLI modules is purely presentation-related, and the code in the engine implements all the logic.&lt;/li&gt;&lt;li&gt;The goal of these changes is to be able to hide the interactions with the database in these controllers. The CLI layer has no business in dealing with the database connection (other than allowing the user to specify which database to talk to, of course).&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Implemented a very simple RAII model for SQLite transactions.&lt;/li&gt;&lt;li&gt;Some additions to the utils::sqlite bindings to simplify some common calling patterns (e.g. binding statement parameters by name).&lt;/li&gt;&lt;li&gt;Preliminary prototypes at database initialization. This involves creating new databases and populating them with the initial schema, plus dealing with database metadata to, e.g. detect if we are dealing with the correct schema version.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;The code for this is still too crappy to be submitted, so don't look for it in the repository just yet!&lt;/li&gt;&lt;li&gt;The design document details many things that should be part of the schema (e.g. "sessions"0, but I've decided that I'll start easy with a simplified schema and later build on top of it. Otherwise there will be too many clunky moving parts to deal with while the fundamental ideas are not yet completely clear.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Fixes to let the code build and run again in NetBSD (macppc at least).&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I've now been stuck for a few days trying to figure out what the best way to implement the conversion of (new) in-memory objects to database objects is, and how to later recover these objects. E.g. what the correct abstractions are to take test case results and put them in the database, and how to retrieve these results to generate reports later on. I now start to have a clear mental picture on how this should look like, but I have yet to see how it will scale.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-402139290656767976?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/402139290656767976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=402139290656767976' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/402139290656767976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/402139290656767976'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/10/kyua-weekly-status-report_23.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4275543087243170349</id><published>2011-10-16T22:55:00.002-04:00</published><updated>2011-10-16T22:55:12.465-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Added support to prepare and execute statements to &lt;tt&gt;utils::sqlite&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;Added the &lt;tt&gt;UTILS_PURE&lt;/tt&gt; definition to tag functions as pure. I should now sweep through old code to apply the attribute where possible.&lt;/li&gt;&lt;li&gt;Created a pkgsrc package for Vera++. Investigating if I can use this tool for coding style validation, as the current code of Kyua is a bit messy in this regard.&lt;/li&gt;&lt;li&gt;Made a quick attempt at getting &lt;tt&gt;kyua test&lt;/tt&gt; record test results in a simple database; success! This was just a proof of concept, so it is not submitted yet.&lt;/li&gt;&lt;li&gt;Started to refactor the code to move many logic constructions from the &lt;tt&gt;cli&lt;/tt&gt; to the &lt;tt&gt;engine&lt;/tt&gt;. With the need to store test results in the database, it's clear that these semantics do not belong in the CLI, but the current code structure do not easily allow this. Need to add some "controller" classes in the &lt;tt&gt;engine&lt;/tt&gt; to hide all the interaction among internal components.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4275543087243170349?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4275543087243170349/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4275543087243170349' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4275543087243170349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4275543087243170349'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/10/kyua-weekly-status-report_16.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5370918960000243408</id><published>2011-10-09T19:37:00.002-04:00</published><updated>2011-10-09T23:47:27.862-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Some more reading on SQLite. The &lt;a href="http://www.amazon.com/Using-SQLite-Jay-Kreibich/dp/0596521189"&gt;Using SQLite&lt;/a&gt; book is close to awesome; very easy to read and full of insightful tips.&lt;/li&gt;&lt;li&gt;Cleaned up my preliminary SQLite wrapper code. Still very incomplete, but I've bitten the bullet and decided to commit the new library as is; otherwise I'll just keep&amp;nbsp;procrastinating. So, ladies and gentlemen, welcome &lt;a href="http://code.google.com/p/kyua/source/detail?r=228"&gt;the new utils::sqlite module in Kyua&lt;/a&gt;. At the moment, this just provides the barebones to open and close a database. I need to start playing around with preparing statements before I can model these in my wrapper classes. (Yes, the API structure is extremely similar to that in &lt;a href="http://code.google.com/p/lutok/"&gt;Lutok&lt;/a&gt;.)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;Update (23:40)&lt;/b&gt;: I sent this too early, thinking I would not have anything nice to report this week either. But as it turns out, I finally had some spare time this late evening and got a chance to submit the extremely-incomplete SQLite C++ bindings I've been toying around with. See the update above! :-)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5370918960000243408?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5370918960000243408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5370918960000243408' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5370918960000243408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5370918960000243408'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/10/kyua-weekly-status-report_09.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2063946456167536880</id><published>2011-10-03T15:37:00.003-04:00</published><updated>2011-10-03T15:37:39.888-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;ul&gt;&lt;li&gt;Unfortunately, not much time this week either :-(&lt;/li&gt;&lt;li&gt;I am currently working on some adjustments to the design document of the database to describe new ideas; the previous design was incomplete in some areas and/or not accurate enough to support the described use cases.&amp;nbsp; However, I've not had the to time to finish these edits and publish them.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2063946456167536880?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2063946456167536880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2063946456167536880' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2063946456167536880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2063946456167536880'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/10/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1017676619421586594</id><published>2011-09-26T18:03:00.004-04:00</published><updated>2011-09-26T18:03:56.972-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Unfortunately, no activity this week other than some brainstorming on the database design.&lt;br /&gt;&lt;br /&gt;Why? My shipment container from Dublin arrived and I spent most of the weekend organizing stuff, setting up my little NetBSD box and attending a friend's wedding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1017676619421586594?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1017676619421586594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1017676619421586594' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1017676619421586594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1017676619421586594'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/kyua-weekly-status-report_26.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6942172427809398844</id><published>2011-09-19T17:57:00.000-04:00</published><updated>2011-09-19T17:57:27.912-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='virtualization'/><title type='text'>VirtualBox and port forwarding (and Fusion)</title><content type='html'>I have been a &lt;a href="http://www.vmware.com/products/fusion/overview.html"&gt;VMware Fusion&lt;/a&gt; user for a long time and I think I am about to be a &lt;a href="http://www.virtualbox.org/"&gt;VirtualBox&lt;/a&gt; convert. Let me explain you my story.&lt;br /&gt;&lt;br /&gt;With the release of the &lt;a href="http://msdn.microsoft.com/en-us/windows/home/br229518"&gt;Windows 8 Developer Preview&lt;/a&gt;, I felt like giving the system a try. Not because I particularly like or care about Windows, but just because I am genuinely curious about operating systems and wanted to check out their new Metro interface. So I went ahead, downloaded the ISO image, created a new virtual machine under Fusion 3, started the virtual machine, and saw Fusion crash while the Windows installer was booting.&lt;br /&gt;&lt;br /&gt;Oh well, an emulation problem. I tried to fiddle with the virtual machine settings a bit, selecting different CPU virtualization settings and different hardware devices. No luck. After that, I resorted to Google to look for a solution to the problem and found that other people were experiencing the same issue. But, at the same time, I also found that VMware had just released Fusion 4 and that this new release works with Windows 8 just fine. Ah, cool! Or not... $50 for the upgrade. For my use cases (which amount to booting a few BSD and Linux virtual machines in console mode), it is hard to justify the upgrade — specially when it would just be to fulfill my curiosity and then delete the virtual machine 10 minutes later.&lt;br /&gt;&lt;br /&gt;But wait! There is that thing called VirtualBox. I had used this product a while ago and did not enjoy doing so because its interface was utterly (really) confusing. It was nowhere near the polish of Fusion or Parallels. However, to my surprise, most of my major itches have been fixed and the new interface of VirtualBox is bearable. And it boots the Windows 8 preview just fine!&lt;br /&gt;&lt;br /&gt;Right. So after installing Windows 8, playing with it for 10 minutes, and later deleting it, I decided to look around and see what else VirtualBox has to offer. It has &lt;i&gt;many&lt;/i&gt; settings. Yes, I know, Fusion has many settings too, but most are hidden from the UI and can only be accessed by modifying the &lt;tt&gt;vmx&lt;/tt&gt; text file. In the case of VirtualBox they are easily accessible.&lt;br /&gt;&lt;br /&gt;I kept looking around... and there it was, the "&lt;b&gt;Port Forwarding&lt;/b&gt;" option staring at me under the Network settings.&lt;br /&gt;&lt;br /&gt;One of the features I've been wishing for a long, long, &lt;i&gt;long&lt;/i&gt; time is the ability to easily configure a NATed (not bridged) virtual machine in my laptop, assign a host name to it from the graphical interface and then be able to SSH into the virtual machine from the laptop. As it turns out, this is doable in Fusion but it requires some nasty tinkering: one has to edit a &lt;i&gt;dhcpd&lt;/i&gt; configuration file by hand to add a new stanza for the virtual machine (&lt;tt&gt;/Library/Application Support/VMware Fusion/vmnet8/dhcpd.conf&lt;/tt&gt;). This involves manually copy/pasting the MAC address of the virtual machine into that file (which you must first extract from the &lt;tt&gt;vmx&lt;/tt&gt; file), assigning it an IP in the corresponding subnet, and sticking the IP plus host name in the &lt;tt&gt;/etc/hosts&lt;/tt&gt; file. This gets boring pretty quickly.&lt;br /&gt;&lt;br /&gt;VirtualBox may or may not support this kind of setting, but it has the aforementioned "Port Forwarding" option which is interesting on its own. As you can imagine, this sets up forwarding of a port from the host system to a port of the virtual machine. Creating an entry for SSH is as easy as clicking a couple of buttons, choosing a local port on the host system (e.g. 2022) and forwarding it to port 22 of the guest system. Voila. You can now access your virtual machine locally &lt;i&gt;and remotely&lt;/i&gt; without having to go through any of the host name nor DHCP madness I experienced before:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;$ ssh -p 2022 localhost&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;You can later create an alias in your &lt;tt&gt;~/.ssh/config&lt;/tt&gt; file to make accessing the virtual machine a breeze:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;Host myvm&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Hostname localhost&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;Port 2022&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;And later:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;$ ssh myvm&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;It couldn't be easier. This trivial feature is a killer for the kind of environment I am interested in. And I also know that VirtualBox provides some other interesting features, like headless mode, that are not (easily) available with Fusion.&lt;br /&gt;&lt;br /&gt;So yes, I think I am a convert.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6942172427809398844?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6942172427809398844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=6942172427809398844' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6942172427809398844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6942172427809398844'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/virtualbox-and-port-forwarding-and.html' title='VirtualBox and port forwarding (and Fusion)'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7580227422862832024</id><published>2011-09-18T19:10:00.000-04:00</published><updated>2011-09-19T07:06:31.317-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='lutok'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report (db designdoc edition!)</title><content type='html'>&lt;ul&gt;&lt;li&gt;Moved the code of &lt;tt&gt;utils::lua&lt;/tt&gt; to a new project, &lt;a href="http://code.google.com/p/lutok/"&gt;Lutok&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Attempted to integrate a copy of Lutok into the Kyua source code to simplify installing Kyua. I have been playing with Subversion externals and Autoconf/Automake hacks to make this happen, but unfortunately haven't got a pleasant solution yet.&lt;/li&gt;&lt;li&gt;Modified Lutok to not expose the Lua C API at all from header files and cleaned up the Kyua code to cope with the changes.&lt;/li&gt;&lt;li&gt;Been chewing through the first chapters of the "&lt;a href="http://www.amazon.com/Using-SQLite-Jay-Kreibich/dp/0596521189"&gt;Using SQLite&lt;/a&gt;" book to refresh my SQL skills. &lt;/li&gt;&lt;li&gt;And, most importantly, wrote a &lt;a href="http://code.google.com/p/kyua/wiki/DatabaseDesign"&gt;preliminary design document for the database store&lt;/a&gt; of Kyua and the reporting features. Comments certainly welcome! Be aware that this is how &lt;tt&gt;atf-report&lt;/tt&gt; will be replaced, so once this is done we should be able to finally kill &lt;tt&gt;atf-run&lt;/tt&gt; and &lt;tt&gt;atf-report&lt;/tt&gt; altogether :-)&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7580227422862832024?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7580227422862832024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7580227422862832024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7580227422862832024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7580227422862832024'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/kyua-weekly-status-report-db-designdoc.html' title='Kyua: Weekly status report (db designdoc edition!)'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7544613249446930628</id><published>2011-09-17T23:26:00.000-04:00</published><updated>2011-09-17T23:26:02.702-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='lutok'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Name your C++ auto-cleaners</title><content type='html'>As you may already know, RAII is a very powerful and popular pattern in the C++ language. With RAII, you can wrap non-stack-managed resources into a stack-managed object such that, when the stack-managed object goes out of scope, it releases the corresponding non-stack-managed object. &lt;a href="http://onlamp.com/pub/a/onlamp/2006/05/04/smart-pointers.html?page=1"&gt;Smart pointers&lt;/a&gt; are just one example of this technique, but so are IO streams too.&lt;br /&gt;&lt;br /&gt;Before getting into the point of the article, bear with me for a second while I explain what the&amp;nbsp; &lt;a href="http://code.google.com/p/lutok/source/browse/trunk/stack_cleaner.hpp"&gt;&lt;tt&gt;stack_cleaner&lt;/tt&gt;&lt;/a&gt; object of &lt;a href="http://code.google.com/p/lutok/"&gt;Lutok&lt;/a&gt; is. The "stack cleaner" takes a reference to a Lua state and records the height of the Lua stack on creation. When the object is destroyed (which happens when the declaring function exits), the stack is returned to its previous height thus ensuring it is clean. It is always a good idea for a function to prevent side-effects by leaving its outside world as it was — and, like it or not, the Lua state is part of the outside world because it is an input/output parameter to many functions.&lt;br /&gt;&lt;br /&gt;Let's consider a piece of code &lt;i&gt;without&lt;/i&gt; using the stack cleaner:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;void&lt;br /&gt;my_function(lutok::state&amp;amp; state, const int foo)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.push_integer(foo);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... do something else in the state ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const int bar = state.to_integer();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (bar != 3) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; state.pop(1); &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw std::runtime_error("Invalid data!");&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; state.pop(1);&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;Note that we have had to call &lt;tt&gt;state.pop(1)&lt;/tt&gt; from "all" exit points of the function to ensure that the stack is left unmodified upon return of &lt;tt&gt;my_function&lt;/tt&gt;. Also note that "all exit points" may not be accurate: in a language that supports exceptions, any statement may potentially raise an exception so to be really safe we should do:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;void&lt;br /&gt;my_function(lutok::state&amp;amp; state, const int foo)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.push_integer(foo);&lt;br /&gt;&amp;nbsp; &amp;nbsp; try { &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; ... do something else in the state ...&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; const int bar = state.to_integer();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; if (bar != 3 &lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw std::runtime_error("Invalid data!");&lt;br /&gt;&amp;nbsp; &amp;nbsp; } catch (...) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; state.pop(1);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.pop(1);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;... which gets old very quickly. Writing this kind of code is error-prone and boring.&lt;br /&gt;&lt;br /&gt;With an "auto-cleaner" object such as the &lt;tt&gt;stack_cleaner&lt;/tt&gt;, we can simplify our code like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;void&lt;br /&gt;my_function(lutok::state&amp;amp; state, const int foo)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; lutok::stack_cleaner cleaner(state);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.push_integer(foo);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... do something else in the state ...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const int bar = state.to_integer();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (bar != 3) &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw std::runtime_error("Invalid data!"); &lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;And we leave the boring task of determining when to actually call &lt;tt&gt;state.pop(1)&lt;/tt&gt; to the compiler and the runtime environment. In this particular case, no matter how the &lt;tt&gt;my_function&lt;/tt&gt; terminates, we ensure that the Lua stack will be left as the same size as it was before.&lt;br /&gt;&lt;br /&gt;But, as I said earlier, all this was just an introduction to the idea that made me write this post.&lt;br /&gt;&lt;br /&gt;When you declare an auto-cleaner object of any kind, &lt;i&gt;be sure to give it a name&lt;/i&gt;. It has happened to me a few times already that I have written the following construct:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;lutok::stack_cleaner(state);&lt;/pre&gt;&lt;br /&gt;... which is syntactically correct, harmless and "looks good" if you don't look closely. The compiler will chew along just fine because, even though we are declaring an anonymous object, its constructor and destructor may be doing who-knows-what, so their code must be called and thus the "unused variable" warning cannot really be raised.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;However&lt;/b&gt; this does not give us the desired behavior. The cleaner object will be constructed and destructed in the same statement without having a chance to wrap any of the following code, because its scope is just the statement in which it was defined. In other words, the cleaner will have absolutely no effect on the rest of the function and thus will be useless.&lt;br /&gt;&lt;br /&gt;So, moral of the story: always give a name to your auto-cleaner objects so that their scope is correctly defined and their destructor is run when you actually expect:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;lutok::stack_cleaner ANY_NAME_HERE(state);&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7544613249446930628?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7544613249446930628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7544613249446930628' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7544613249446930628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7544613249446930628'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/name-your-c-auto-cleaners.html' title='Name your C++ auto-cleaners'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7627076009086318140</id><published>2011-09-15T15:18:00.000-04:00</published><updated>2011-09-15T15:19:02.820-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='lutok'/><category scheme='http://www.blogger.com/atom/ns#' term='announce'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Introducing Lutok: A lightweight C++ API for Lua</title><content type='html'>It has finally happened. &lt;a href="http://code.google.com/p/lutok/"&gt;Lutok&lt;/a&gt; is the result of what was promised in the "&lt;a href="http://blog.julipedia.org/2011/09/splitting-utilslua-from-kyua.html"&gt;Splitting utils::lua from Kyua&lt;/a&gt;" web post.&lt;br /&gt;&lt;br /&gt;Quoting the project web page:&lt;br /&gt;&lt;blockquote&gt;Lutok provides thin C++ wrappers around the Lua C API to ease the interaction between C++ and Lua. These wrappers make intensive use of RAII to prevent resource leakage, expose C++-friendly data types, report errors by means of exceptions and ensure that the Lua stack is always left untouched in the face of errors. The library also provides a small subset of miscellaneous utility functions built on top of the wrappers.&lt;br /&gt;&lt;br /&gt;Lutok focuses on providing a clean and safe C++ interface; the drawback is that it is not suitable for performance-critical environments. In order to implement error-safe C++ wrappers on top of a Lua C binary library, Lutok adds several layers or abstraction and error checking that go against the original spirit of the Lua C API and thus degrade performance.&lt;br /&gt;&lt;br /&gt;Lutok was originally developed within Kyua but was later split into its own project to make it available to general developers.&lt;/blockquote&gt;Coming up with a name for this project was quite an odyssey, and is what has delayed is release more than I wanted. My original candidate was "luawrap" which, although not very original, was to-the-point and easy to understand. Unfortunately, that name did not clear with the legal department and I had to propose several other names, some of which were not acceptable either. Eventually, I settled with "Lutok", which comes from "LUa TOolKit".&lt;br /&gt;&lt;br /&gt;At this point, the source tree of Lutok provides pretty much the same code as the &lt;tt&gt;utils::lua&lt;/tt&gt; module of Kyua. While it may be enough to get you started, I'm pretty sure you will lack some functions in the &lt;tt&gt;state&lt;/tt&gt; class. If that is the case, don't hesitate to file a bug report to let me know what is missing.&lt;br /&gt;&lt;br /&gt;In case you missed the link above, the project page is here: &lt;a href="http://code.google.com/p/lutok/"&gt;Lutok in Google Code&lt;/a&gt;. &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7627076009086318140?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7627076009086318140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7627076009086318140' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7627076009086318140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7627076009086318140'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/introducing-lutok-lightweight-c-api-for.html' title='Introducing Lutok: A lightweight C++ API for Lua'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2547470671733170941</id><published>2011-09-12T22:34:00.000-04:00</published><updated>2011-09-15T18:42:31.234-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c'/><category scheme='http://www.blogger.com/atom/ns#' term='portability'/><title type='text'>Using va_copy to safely pass ap arguments around</title><content type='html'>A long time ago, while I was preparing an ATF release, I faced many failing tests and crashes in one of the platforms under test. My memory told me this was a problem in OpenSolaris, but the &lt;a href="http://www.blogger.com/mtn-host.prjek.net/viewmtn/atf/revision/info/655c6c51f2155076f482a038042c67fd25adc934"&gt;repository logs&lt;/a&gt; say that the problem really happened in Fedora 8 x86_64.&lt;br /&gt;The problem manifested itself as segmentation faults pretty much everywhere, and I could trace such crashes down to pieces of code like the following, of which the C code of ATF is full of:&lt;br /&gt;&lt;pre&gt;void&lt;br /&gt;foo_fmt(const char *fmt, ...)&lt;br /&gt;{&lt;br /&gt;    va_list ap;&lt;br /&gt;&lt;br /&gt;    va_start(ap, fmt);&lt;br /&gt;    foo_ap(fmt, ap);&lt;br /&gt;    va_end(ap);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;foo_ap(const char *fmt, va_list ap)&lt;br /&gt;{&lt;br /&gt;    char buf[128];&lt;br /&gt;&lt;br /&gt;    vsnprintf(buf, sizeof(buf), fmt, ap);&lt;br /&gt;&lt;br /&gt;    ... now, do something with buf ...&lt;br /&gt;}&lt;/pre&gt;The codebase of ATF provides &lt;tt&gt;_fmt&lt;/tt&gt; and &lt;tt&gt;_ap&lt;/tt&gt; variants for many functions to give more flexibility to the caller and, as shown above, the &lt;tt&gt;_fmt&lt;/tt&gt; variant just relies on the &lt;tt&gt;_ap&lt;/tt&gt; variant to do the real work.&lt;br /&gt;Now, the crashes that appeared from the code above seemed to come from the call that consumes the &lt;tt&gt;ap&lt;/tt&gt; argument, which in this case is &lt;tt&gt;vsnprintf&lt;/tt&gt;. Interestingly, though, all the tests in other platforms but Linux x86_64 worked just fine, and this included OpenSolaris, other Linux distributions, some BSDs and even different hardware platforms.&lt;br /&gt;As it turned out, you &lt;b&gt;cannot blindly pass &lt;tt&gt;ap&lt;/tt&gt; arguments around&lt;/b&gt; because they are not "normal" parameters (even though, unfortunately, they look like so!). In most platforms, the &lt;tt&gt;ap&lt;/tt&gt; element will be just an "absolute" pointer to the stack, so passing the variable to an inner function calls is fine because the caller's stack has not been destroyed yet and, therefore, the pointer is still valid. But... the &lt;tt&gt;ap&lt;/tt&gt; argument can have other representations. It'd be an offset to the stack instead of a pointer, or it'd be a data structure that holds all the variable parameters. If, for example, the &lt;tt&gt;ap&lt;/tt&gt; argument held an offset, passing it to an inner function call would make such offset point to "garbage" because the stack would have been grown due to the new call frame. (I haven't investigated what specific representation is x86_64 using.)&lt;br /&gt;The solution is to use the &lt;tt&gt;va_copy&lt;/tt&gt; function to generate a new &lt;tt&gt;ap&lt;/tt&gt; object that is valid for the current stack frame. This is easy, so as an example, we have to rewrite the &lt;tt&gt;foo_ap&lt;/tt&gt; function above as follows:&lt;br /&gt;&lt;pre&gt;void&lt;br /&gt;foo_ap(const char *fmt, va_list ap)&lt;br /&gt;{&lt;br /&gt;    char buf[128];&lt;br /&gt;    va_list ap2;&lt;br /&gt;&lt;br /&gt;    va_copy(ap2, ap);&lt;br /&gt;    vsnprintf(buf, sizeof(buf), fmt, ap2);&lt;br /&gt;    va_end(ap2);&lt;br /&gt;&lt;br /&gt;    ... now, do something with buf ...&lt;br /&gt;}&lt;/pre&gt;This duplication of the &lt;tt&gt;ap&lt;/tt&gt; argument pointing to the variable list of arguments ensures that &lt;tt&gt;ap2&lt;/tt&gt; can be safely used from the new stack frame.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2547470671733170941?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2547470671733170941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2547470671733170941' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2547470671733170941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2547470671733170941'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/using-vacopy-to-safely-pass-ap.html' title='Using va_copy to safely pass ap arguments around'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2227882804331509588</id><published>2011-09-12T10:12:00.003-04:00</published><updated>2011-09-12T22:37:03.383-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;ul&gt;&lt;li&gt;My plan for this week was to release utils::lua as a separate module. Unfortunately, this has not been possible because I've been fighting with legal to clear the name for the project. I don't have an approved name yet, so this will have to wait a bit more :-(&lt;/li&gt;&lt;li&gt;On another order of things, I have started writing a design document for the database that will collect test case results and other information. Will share it as soon as it is readable and more or less complete.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2227882804331509588?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2227882804331509588/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2227882804331509588' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2227882804331509588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2227882804331509588'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/kyua-weekly-status-report_12.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/05472505959624132834</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8210083915264683632</id><published>2011-09-06T18:05:00.002-04:00</published><updated>2011-09-06T18:05:25.223-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='m4'/><category scheme='http://www.blogger.com/atom/ns#' term='autoconf'/><title type='text'>Diversions in Autoconf (actually, in M4sugar)</title><content type='html'>Have you ever wondered how Autoconf reorganizes certain parts of your script regardless of the order in which you invoke the macros in your &lt;tt&gt;configure.ac&lt;/tt&gt; script? For example, how come you can define &lt;tt&gt;--with-*&lt;/tt&gt; and &lt;tt&gt;--enable-*&lt;/tt&gt; flags anywhere in your script and these are all magically moved to the option-processing section of the final shell script? After all, Autoconf is just a collection of M4 macros, and a macro preprocessor's only work is to expand macros in the input with predefined output texts. Isn't it?&lt;br /&gt;&lt;br /&gt;Enter &lt;a href="http://www.gnu.org/s/hello/manual/autoconf/Diversion-support.html#Diversion-support"&gt;M4sugar's diversions&lt;/a&gt;. Diversions are a mechanism that allows M4 macros to output code to different text blocks, which are later concatenated in a specific order to form the final script.&lt;br /&gt;&lt;br /&gt;Let's consider an example (based on a few M4 macros to &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/file/7ae5fa10200ec66c26f08c27e4aeaf3facf3f031/atf-c/atf-common.m4"&gt;detect the ATF bindings&lt;/a&gt; from your own configure scripts). Suppose you want to define a macro &lt;tt&gt;FROB_ARG&lt;/tt&gt; to provide a &lt;tt&gt;--with-frob&lt;/tt&gt; argument whose argument must be either "yes" or "no". Also suppose you want to have another macro &lt;tt&gt;FROB_CHECK&lt;/tt&gt; to detect whether &lt;tt&gt;libfrob&lt;/tt&gt; exists. Lastly, you want the user to be able to use these two independently: when &lt;tt&gt;FROB_CHECK&lt;/tt&gt; is used &lt;i&gt;without&lt;/i&gt; invoking &lt;tt&gt;FROB_ARG&lt;/tt&gt; first, you want it to unconditionally look for the library; otherwise, if &lt;tt&gt;FROB_ARG&lt;/tt&gt; has been used, you want to honor its value.&lt;br /&gt;&lt;br /&gt;We could define these macros as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;AC_DEFUN([FROB_ARG], [&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AC_ARG_WITH([frob],&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [AS_HELP_STRING([--with-frob=yes|no], [enable frob])],&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [with_frob=${withval}, [with_frob=yes]) &lt;br /&gt;])&lt;br /&gt;&lt;br /&gt;AC_DEFUN([FROB_CHECK], [&lt;br /&gt;&amp;nbsp; &amp;nbsp; m4_divert_text([DEFAULTS], [with_frob=yes])&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; if test "${with_frob}" = yes; then&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ... code to search for libfrob ... &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif test "${with_frob}" = no; then&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :&amp;nbsp; # Nothing to do. &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AC_MSG_ERROR([--with-frob must be yes or not]) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;])&lt;/pre&gt;&lt;br /&gt;Note the &lt;tt&gt;m4_divert_text&lt;/tt&gt; call above: this macro invocation tells M4sugar to store the given text (&lt;tt&gt;with_frob=yes&lt;/tt&gt;) in the &lt;tt&gt;DEFAULTS&lt;/tt&gt; diversion. When the script is later generated, this text will appear at the beginning of the script before the command-line options are processed, completely separated from the shell logic that consumes this value later on.&lt;br /&gt;&lt;br /&gt;With this we ensure that the &lt;tt&gt;with_frob&lt;/tt&gt; shell variable is always defined regardless of the call to the &lt;tt&gt;FROB_ARG&lt;/tt&gt; macro. If this macro is called, &lt;tt&gt;with_frob&lt;/tt&gt; will be defined during the processing of the options and will override the value of the variable defined in the &lt;tt&gt;DEFAULTS&lt;/tt&gt; section. However, if the macro has not been called, the variable will keep its default value for the duration of the script.&lt;br /&gt;&lt;br /&gt;Of course, this example is fictitious and could be simplified in other ways. But, as you can see in the &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/file/7ae5fa10200ec66c26f08c27e4aeaf3facf3f031/atf-c/atf-common.m4"&gt;referred change&lt;/a&gt; and in the Autoconf code itself, diversions are extensively used for trickier purposes. In fact, Autoconf uses diversions to topologically sort macro dependencies in your script and output them in a specific order to satisfy cross-dependencies.&lt;br /&gt;&lt;br /&gt;Isn't that cool?&amp;nbsp; I can't cease to be amazed, but I also don't dare to look at how this works internally for my own sanity...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8210083915264683632?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8210083915264683632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8210083915264683632' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8210083915264683632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8210083915264683632'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/diversions-in-autoconf-actually-in.html' title='Diversions in Autoconf (actually, in M4sugar)'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1340557741979574423</id><published>2011-09-04T20:36:00.002-04:00</published><updated>2011-09-04T20:37:01.069-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nyc'/><category scheme='http://www.blogger.com/atom/ns#' term='photos'/><title type='text'>Introducing "Dirt and the City"</title><content type='html'>A friend of mine recently started a blog called &lt;a href="http://dirtandthecity.blogspot.com/"&gt;Dirt and the City&lt;/a&gt; and, because he has invited me to contribute to it, I feel like posting a reference here ;-)&lt;br /&gt;&lt;br /&gt;Dirt and the City is a blog that intends to show you the "ugly" (literally) side of NYC. The blog is named after a famous TV show filmed in this same city; I haven't watched the show myself, but I bet that there is no dirt to be seen in it. If you are wondering what the city really looks like, this blog is your place.&lt;br /&gt;&lt;br /&gt;But, before visiting the blog, be sure to take it as it is meant to be: just a fun collection of photos! If you ever want to visit NYC, don't let the contents of the blog change your plans. You will definitely enjoy your visit regardless.&lt;br /&gt;&lt;br /&gt;Without further ado, and just in case you missed the link above, &lt;a href="http://dirtandthecity.blogspot.com/"&gt;click here to visit Dirt and the City&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1340557741979574423?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1340557741979574423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1340557741979574423' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1340557741979574423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1340557741979574423'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/introducing-dirt-and-city.html' title='Introducing &quot;Dirt and the City&quot;'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4612027995169805955</id><published>2011-09-04T20:28:00.001-04:00</published><updated>2011-09-04T20:28:19.116-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Slow week.&amp;nbsp; We had some team-related events at work and I have friends over from Dublin, so it has been hard to find some time to do work on Kyua.&amp;nbsp; Regardless, here comes the weekly report: &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Split utils::lua into its own package, per some user's request.&amp;nbsp; I'm still setting up the separate project and have to do lots of cleanup on the code, so nothing is available yet.&lt;/li&gt;&lt;li&gt;Started experimenting on the long promised "tests results database".&amp;nbsp; So far, I have started writing a small utils::sqlite3 C++, RAII-based wrapper for SQLite 3 and a SQL schema for the database.&amp;nbsp; My rusty SQL skills don't help :-P&lt;/li&gt;&lt;/ul&gt;However, all this work is local so there have been no commits to the repository this week; sorry!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4612027995169805955?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4612027995169805955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4612027995169805955' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4612027995169805955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4612027995169805955'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7776434088222789247</id><published>2011-09-03T09:43:00.001-04:00</published><updated>2011-09-03T09:43:31.956-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Splitting utils::lua from Kyua</title><content type='html'>If you remember a post from January titled &lt;a href="http://blog.julipedia.org/2011/01/c-interface-to-lua.html"&gt;C++ interface to Lua for Kyua&lt;/a&gt; (wow, time flies), the Kyua codebase includes a small library to wrap the native Lua C library into a more natural C++ interface. You can take a look at the &lt;a href="http://code.google.com/p/kyua/source/browse/#svn%2Ftags%2Fkyua-cli-0.2%2Futils%2Flua%253Fstate%253Dclosed"&gt;current code as of r129&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Quoting the previous post:&lt;br /&gt;&lt;blockquote&gt;The utils::lua library provides thin C++ wrappers around the Lua C API to ease the interaction between C++ and Lua.  These wrappers make intensive use of RAII to prevent resource leakage, expose C++-friendly data types, report errors by means of exceptions and ensure that the Lua stack is always left untouched in the face of errors.  The library also provides a place (the operations module) to add miscellaneous utility functions built on top of the wrappers.&lt;/blockquote&gt;While the RAII wrappers and other C++-specific constructions are a very nice thing to have, this library has to jump through a lot of hoops to interact with binary Lua versions built for C. This makes utils::lua not usable for performance-critical environments. Things would be way easier if utils::lua linked to a Lua binary built for C++, but unfortunately that is not viable in most, if not all, systems with binary packaging systems (read: most Linux distributions, BSD systems, etc.).&lt;br /&gt;&lt;br /&gt;That said, I've had requests from a bunch of people to provide utils::lua separately from Kyua regardless of any performance shortcomings it may have, and this is what I have started doing this weekend. So far, I already have a pretty clumsy standalone package (I'll keep the name to myself for now ;-) that provides this library on its own with the traditional Automake, Autoconf and Libtool support. Once this is a bit better quality, and once I modify Kyua to link against this external library and assess that things work fine, I'll make the decision on how to publish this (but most likely it should be a separate project in Google Code).&lt;br /&gt;&lt;br /&gt;Splitting the code doesn't come with its own issues though: maintaining a separate package will involve more work and hopefully/supposedly, dealing with quite a few feature requests to add missing functionality! Also, it means that utils::lua cannot use any of the other Kyua libraries (utils::sanity for example), so I lose a bit of consistency across the Kyua codebase. I am also not sure about how to share non-library code (in particular, the m4 macros for Autoconf) across the two packages.&lt;br /&gt;&lt;br /&gt;So, my question is: are you interested in utils::lua being shipped separately? :-)&amp;nbsp; Do you have any cool use cases for it that you can share here?&lt;br /&gt;&lt;br /&gt;Thanks!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7776434088222789247?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7776434088222789247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7776434088222789247' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7776434088222789247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7776434088222789247'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/09/splitting-utilslua-from-kyua.html' title='Splitting utils::lua from Kyua'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/05472505959624132834</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5526887000020160198</id><published>2011-08-28T18:48:00.002-04:00</published><updated>2011-08-28T18:59:26.872-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Not a very active week: I've been on-call four days and they have been quite intense. Plus I have had to go through a "hurricane" in NYC. That said, I had some time to do a bit of work on Kyua and the results have been nice :-)&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Made calls to &lt;span style="font-weight: bold;"&gt;getopt_long(3)&lt;/span&gt; work with GNU Getopt by using the correct value of optind to reset option processing.&lt;/li&gt;&lt;li&gt;Improved the configure script to error out in a clearer way when missing dependencies (pkg.m4 and Lua) are not found.&lt;/li&gt;&lt;li&gt;Did some portability fixes.&lt;/li&gt;&lt;li&gt;And &lt;a href="http://blog.julipedia.org/2011/08/kyua-02-released.html"&gt;released Kyua 0.2&lt;/a&gt;! (along with a pkgsrc package)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;At this point, I have to start thinking how to implement test suite reporting within Kyua (i.e. how to replace &lt;span style="font-weight: bold;"&gt;atf-report&lt;/span&gt;). This probably means learning SQLite and refreshing my incredibly rusty SQL skills.&lt;br /&gt;&lt;br /&gt;Also, it's time to (probably) split the &lt;span style="font-weight: bold;"&gt;utils::lua&lt;/span&gt; library in a separate package because there is several people interested in this.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5526887000020160198?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5526887000020160198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5526887000020160198' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5526887000020160198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5526887000020160198'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/08/kyua-weekly-status-report_28.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/05472505959624132834</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1596231568841558285</id><published>2011-08-24T17:09:00.000-04:00</published><updated>2011-08-24T17:09:41.692-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='release'/><title type='text'>Kyua 0.2 released</title><content type='html'>Dear readers,&lt;br /&gt;&lt;br /&gt;I am very proud to announce the second formal release of &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt;, 0.2. &amp;nbsp;This release comes with lots of internal changes and a few user-visible changes. &amp;nbsp;Instead of listing all the changes and news here, I'll just recommend you to visit the &lt;a href="http://code.google.com/p/kyua/downloads/detail?name=kyua-cli-0.2.tar.gz"&gt;0.2 release page&lt;/a&gt; and read all the notes.&lt;br /&gt;&lt;br /&gt;This release has been tested under NetBSD-current, Mac OS X Snow Leopard, Debian sid and Ubuntu 10.04.1 LTS.&lt;br /&gt;&lt;br /&gt;Please report any problems that you encounter.&lt;br /&gt;&lt;br /&gt;Have fun!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1596231568841558285?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1596231568841558285/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1596231568841558285' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1596231568841558285'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1596231568841558285'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/08/kyua-02-released.html' title='Kyua 0.2 released'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7414758102724054678</id><published>2011-08-21T23:47:00.000-04:00</published><updated>2011-08-21T23:47:48.741-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Implemented the "debug" command. Still very rudimentary, this command allows the user to run a test case without capturing its stdout nor stderr to aid in debugging of failed test cases. In the future, this command will also allow things like keeping the work directory for manual inspection, or spawning a shell or a debugger in the work directory after a test case is executed.&lt;/li&gt;&lt;li&gt;Many build fixes under different platforms in preparation for a 0.2 release. In particular, Kyua now builds under Ubuntu 10.04.1 LTS but some tests fail.&lt;/li&gt;&lt;li&gt;Had to disable the execution of the bootstrap test suite within Kyua because it stalls in systems where the default shell is not bash. &amp;nbsp;I presume this is a bug in GNU Autotest, so I &lt;a href="https://lists.gnu.org/archive/html/bug-autoconf/2011-08/msg00009.html"&gt;filed a report&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7414758102724054678?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7414758102724054678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7414758102724054678' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7414758102724054678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7414758102724054678'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/08/kyua-weekly-status-report_22.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-3044570526739158979</id><published>2011-08-15T09:13:00.001-04:00</published><updated>2011-08-16T12:26:51.242-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;ul&gt;&lt;li&gt;Changed the &lt;tt&gt;--config&lt;/tt&gt; and &lt;tt&gt;--variable&lt;/tt&gt; options to be program-wide instead of command-specific. The configuration file should be able to hold properties that tune the behavior of Kyua, not just the execution of tests, so this makes sense.&lt;/li&gt;&lt;li&gt;Added the &lt;tt&gt;config&lt;/tt&gt; subcommand, which provides a way to inspect the configuration as read by Kyua.&lt;/li&gt;&lt;li&gt;Got rid of the &lt;tt&gt;test_suites_var&lt;/tt&gt; function from configuration files and replaced it by simple assignments to variables in the &lt;tt&gt;test_suites&lt;/tt&gt; global table.&lt;/li&gt;&lt;li&gt;Enabled detection of unused parameters by the compiler and fixed all warnings.&lt;/li&gt;&lt;li&gt;Changed developer mode to only control whether warnings are enforced or not (not to enable the warnings themselves) and made developer mode be disabled on formal releases.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Barring release testing, Kyua 0.2 should be ready soon :-)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-3044570526739158979?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/3044570526739158979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=3044570526739158979' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3044570526739158979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3044570526739158979'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/08/kyua-weekly-status-report_15.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1533426319378637169</id><published>2011-08-08T12:30:00.000-04:00</published><updated>2011-08-08T12:30:45.540-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Added the ability to explicitly define timeouts for plain test programs. This just completes the work from past week that made running plain test programs at all but had an ugly TODO in it to implement this missing feature.&lt;/li&gt;&lt;li&gt;The bootstrap test suite now runs as a single test case within the whole Kyua test suite. Demonstrates the plain test programs interface functionality :-)&lt;/li&gt;&lt;li&gt;Started reshuffling code to make the &amp;lt;tt&amp;gt;--config&amp;lt;/tt&amp;gt; and related flags program-wide. The goal is to allow the configuration file to tune the behavior of all of Kyua, so these flags must be made generic. They were previously specific to the &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; subcommand only.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1533426319378637169?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1533426319378637169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1533426319378637169' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1533426319378637169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1533426319378637169'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/08/kyua-weekly-status-report_08.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-374370690899258269</id><published>2011-08-01T10:51:00.000-04:00</published><updated>2011-08-01T10:51:53.347-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;ul&gt;&lt;li&gt;Implemented the "plain" test interface. This allows plugging "foreign test programs" into a Kyua-based test suite. (A foreign test program is a program that does not use any testing framework: it reports success and failure by means of an exit code.)&lt;/li&gt;&lt;li&gt;Generalized code between the atf and plain interfaces and did some cleanups.&lt;/li&gt;&lt;li&gt;Attempted to fix the ATF_REQUIRE_EQ macros in ATF to evaluate their arguments only once. This has proven to be tricky and therefore it is not done yet. At the moment, the macros reevaluate the arguments on a failure condition, which is not too big of a deal.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-374370690899258269?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/374370690899258269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=374370690899258269' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/374370690899258269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/374370690899258269'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/08/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2722636504074505217</id><published>2011-07-25T09:51:00.000-04:00</published><updated>2011-07-25T09:51:49.091-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;ul&gt;&lt;li&gt;Finished splitting the atf-specific code from the generic structures in the engine. The engine now supports the addition of extra test interfaces with minimal effort.&lt;/li&gt;&lt;li&gt;Started implementing a "plain" test interface for test programs that do not use any test framework. This is to allow muxing non-atf tests into atf-based test cases, which is required in the NetBSD tree.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2722636504074505217?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2722636504074505217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2722636504074505217' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2722636504074505217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2722636504074505217'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/07/kyua-weekly-status-report_25.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8592499942190203696</id><published>2011-07-18T12:49:00.000-04:00</published><updated>2011-07-18T12:49:55.036-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Slow week. I've been busy moving to NYC!&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Kept working on the splitting of ATF-specific code from the core test abstractions. The work is now focused on refactoring the results-reporting pieces of the code, which are non-trivial.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8592499942190203696?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8592499942190203696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8592499942190203696' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8592499942190203696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8592499942190203696'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/07/kyua-weekly-status-report_18.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-3258163229524946668</id><published>2011-07-10T17:40:00.000-04:00</published><updated>2011-07-10T17:40:01.260-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>One of the major features I want in place for Kyua 0.2 is the ability to run "foreign" test programs as part of a test suite: i.e. to be able to plug non-ATF test programs into a Kyuafile. The rationale for this is to lower the entry barrier of newcomers to Kyua and, also, to allow running some foreign test suites that exist in the NetBSD source tree but that are currently not run.&lt;br /&gt;&lt;br /&gt;The work this week has gone in the direction outlined above among other things:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Created an abstract base class to represent test programs and provided an implementation for ATF.&lt;/li&gt;&lt;li&gt;Did the same thing for test cases.&lt;/li&gt;&lt;li&gt;Moved the kyua-cli package from pkgsrc-wip into pkgsrc head. Installing Kyua is now a breeze under NetBSD (and possibly under other platforms supported by pkgsrc!) &lt;/li&gt;&lt;/ul&gt;The next steps are to generalize the test case results, clearly separate the ATF-specific code from the general abstractions, and add an implementation to run simple test programs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-3258163229524946668?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/3258163229524946668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=3258163229524946668' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3258163229524946668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3258163229524946668'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/07/kyua-weekly-status-report_10.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5656079300726884043</id><published>2011-07-05T03:20:00.002-04:00</published><updated>2011-07-05T03:24:27.028-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Belated update:&lt;div&gt;&lt;ul&gt;&lt;li&gt;Created a pkgsrc package for kyua-cli. Still in pkgsrc-wip though because pkgsrc is in a feature freeze.&lt;/li&gt;&lt;li&gt;Wrote a little tutorial on &lt;a href="http://code.google.com/p/kyua/wiki/HowtoRunNetBSDTests"&gt;how to run NetBSD tests using Kyua&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Started work on 0.2 by doing a minor UI fix in the about command.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I've now started to look at how to split the engine into different "runners" to add support for test programs written without ATF. Not that I plan to use this feature... but having it in place will ensure that the internal interfaces are clean and may help in adoption of Kyua.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5656079300726884043?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5656079300726884043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5656079300726884043' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5656079300726884043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5656079300726884043'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/07/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/05472505959624132834</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4699920604153781702</id><published>2011-06-26T15:51:00.000-04:00</published><updated>2011-06-26T15:51:14.058-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>This has been the big week:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Wrote some user documentation for the kyua binary.&lt;/li&gt;&lt;li&gt;Fixed some distcheck problems.&lt;/li&gt;&lt;li&gt;&lt;a href="http://blog.julipedia.org/2011/06/kyua-01-released.html"&gt;Released Kyua 0.1&lt;/a&gt;!&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;The next immediate thing to do is to write a short tutorial on how to run the NetBSD tests with Kyua and get some people to actually try it. After that, there are many things to improve and features to add :-)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4699920604153781702?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4699920604153781702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4699920604153781702' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4699920604153781702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4699920604153781702'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/06/kyua-weekly-status-report_26.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2206180394296674679</id><published>2011-06-23T12:44:00.000-04:00</published><updated>2011-06-23T12:44:20.977-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='release'/><title type='text'>Kyua 0.1 released!</title><content type='html'>Dear readers,&lt;br /&gt;&lt;br /&gt;I'm very proud to announce that the very first release of &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt;, obviously numbered 0.1, has been published! The release page for &lt;a href="http://code.google.com/p/kyua/downloads/detail?name=kyua-cli-0.1.tar.gz"&gt;kyua-cli-0.1&lt;/a&gt; contains more details about what this release offers, and don't hesitate to join the kyua-discuss mailing list and ask if you have questions.&lt;br /&gt;&lt;br /&gt;Kyua was started sometime in past October and it has taken over six months to get the first public version. (It is true that my free time has heavily fluctuated during this period though, so it does not mean that six months of intensive coding have gone into the release ;-) Kyua 0.1 hovers at almost &lt;a href="https://www.ohloh.net/p/kyua"&gt;40K lines of code according to Ohloh&lt;/a&gt;&amp;nbsp;and comes with 800 test cases, yet it&amp;nbsp;only implements a replacement for the atf-run component of &lt;a href="http://www.netbsd.org/~jmmv/atf/"&gt;ATF&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I have a package ready for pkgsrc, but unfortunately can't submit it because pkgsrc is in a freeze in preparation for the next stable branch. No matter what, expect detailed instructions on how to install Kyua and how to run the NetBSD-current test suite with it very soon.&lt;br /&gt;&lt;br /&gt;Enjoy, and keep the bug reports coming!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2206180394296674679?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2206180394296674679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2206180394296674679' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2206180394296674679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2206180394296674679'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/06/kyua-01-released.html' title='Kyua 0.1 released!'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7980956098536633451</id><published>2011-06-19T16:10:00.000-04:00</published><updated>2011-06-19T16:10:44.091-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>A couple of things have happened:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.netbsd.org/%7Ejmmv/atf/news.html#20110614-atf-0-14-released"&gt;Released ATF 0.14&lt;/a&gt;. This release was followed by an import into NetBSD and fixing of subsequent fallout.&lt;/li&gt;&lt;li&gt;Some performance improvements to atf-sh. After killing a bunch of complex shell constructions and removing lots of obsolete functions, the performance results are significant. There is still room for improvement of course, and I still need to quantify how these optimizations behave in single-core machines.&lt;/li&gt;&lt;/ul&gt;I certainly expected more progress this past week... but in case you don't know: I am moving countries very soon now, and as the move date approaches, there is more and more stuff to be done at home so less and less time for hacking.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7980956098536633451?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7980956098536633451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7980956098536633451' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7980956098536633451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7980956098536633451'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/06/kyua-weekly-status-report_19.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1081629551652690013</id><published>2011-06-17T11:40:00.000-04:00</published><updated>2011-06-17T11:40:16.546-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Validating format strings in custom C functions</title><content type='html'>In C, particularly due to the lack of dynamic strings, it's common to pass format strings around together with a variable set of arguments. A prototype like this is very common:&lt;br /&gt;&lt;br /&gt;&lt;tt&gt;void&amp;nbsp;my_printf(const char*, ...);&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;For the standard &lt;tt&gt;printf&lt;/tt&gt; and similar functions, some compilers will ensure that the variable list of arguments matches the positional parameters in the format string and, if they don't match, raise a warning. &amp;nbsp;This is, however, just a warning "hardcoded" to match these functions, as the compiler can't know how the variable arguments of our custom &lt;tt&gt;my_printf&lt;/tt&gt; function relate to the first argument.&lt;br /&gt;&lt;br /&gt;Or can it?&lt;br /&gt;&lt;br /&gt;&lt;a href="http://mail-index.netbsd.org/source-changes/2011/06/11/msg023084.html"&gt;I was made aware&lt;/a&gt; of a nice GCC attribute that allows developers to tag printf-like functions in a manner that allows the compiler to perform the same validation of variable arguments and format strings. &amp;nbsp;This is in the form of a GCC &lt;tt&gt;__attribute__&lt;/tt&gt; that also happens to work with CLang. &amp;nbsp;Let's see an example to illustrate how this works:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;#include &amp;lt;stdarg.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;static void my_printf(const char*, ...)&lt;br /&gt;&amp;nbsp; &amp;nbsp; __attribute__((format(printf, 1, 2)));&lt;br /&gt;&lt;br /&gt;static void&lt;br /&gt;my_printf(const char* format, ...)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; va_list ap;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; printf("Custom printf: ");&lt;br /&gt;&amp;nbsp; &amp;nbsp; va_start(ap, format);&lt;br /&gt;&amp;nbsp; &amp;nbsp; vprintf(format, ap);&lt;br /&gt;&amp;nbsp; &amp;nbsp; va_end(ap);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main(void)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; my_printf("this is valid %d\n", 3);&lt;br /&gt;&amp;nbsp; &amp;nbsp; my_printf("but this is not %f\n", 3);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;If we compile the code above:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;$&amp;nbsp;clang example.c&lt;br /&gt;example.c:22:33: warning: conversion specifies type 'double' but&lt;br /&gt;the argument has type 'int' [-Wformat]&lt;br /&gt;&amp;nbsp; &amp;nbsp; my_printf("but this is not %f\n", 3);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;~^ &amp;nbsp; &amp;nbsp; ~&lt;br /&gt;1 warning generated.&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Very useful. &amp;nbsp;This function attribute has been applied to many functions in the NetBSD tree and many bugs have been spotted thanks to it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Instead of me explaining how the format attribute works, I'll refer you to the &lt;a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes"&gt;official documentation&lt;/a&gt;. The attribute recognizes several format styles and takes different arguments depending on them, so it is a bit tricky to explain. Plus, if you look at the extensive list of attributes, you may find some useful stuff ;-)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Happy debugging!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1081629551652690013?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1081629551652690013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1081629551652690013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1081629551652690013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1081629551652690013'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/06/validating-format-strings-in-custom-c.html' title='Validating format strings in custom C functions'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7622333407771344296</id><published>2011-06-13T08:03:00.000-04:00</published><updated>2011-06-13T08:03:31.966-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;div&gt;&lt;ul&gt;&lt;li&gt;Added support for recursion from the top-level Kyuafile. This Kyuafile should not reference any directories explicitly because the directories at the top level are supposed to be created by the installation of packages. Closed &lt;a href="http://code.google.com/p/kyua/issues/detail?id=9&amp;amp;can=1"&gt;issue 9&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Improved error messages when the test programs are bogus. Closed &lt;a href="http://code.google.com/p/kyua/issues/detail?id=13&amp;amp;can=1"&gt;issue 13&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Backported format-printf attribute improvements from NetBSD head to ATF.&lt;/li&gt;&lt;li&gt;Miscellaneous build and run fixes for both Kyua and ATF in NetBSD and OS X.&lt;/li&gt;&lt;li&gt;Cut a release candidate for atf-0.14 and started testing on NetBSD.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;The kyua-cli codebase is now feature complete. Blocking the 0.1 release are the need to polish the release documents and the requirement of releasing atf-0.14 beforehand. Should happen soon :-)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7622333407771344296?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7622333407771344296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7622333407771344296' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7622333407771344296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7622333407771344296'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/06/kyua-weekly-status-report_13.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7087754596598489612</id><published>2011-06-05T14:58:00.000-04:00</published><updated>2011-06-05T14:58:56.040-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Some long-standing bug fixes / improvements have gone in this week:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Improvements to the cleanup routine, which is used to destroy the work directory of a test case after the test case has terminated:&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Heavy refactoring to be tolerant to failures. These failures may arise when a child of the test case does not exit immediately and holds temporary files in the work directory open for longer than expected.&lt;/li&gt;&lt;li&gt;Any file systems that the test case leaves mounted within the work directory will now be unmounted, just as the ATF test interface mandates. I realize that this adds a lot of complexity to the runtime engine for very little gain. If/when we revise the tests interface, it will be worth to reconsider this and maybe leave the cleanup of mounted file systems to the test case altogether.&lt;/li&gt;&lt;li&gt;As a result, &lt;a href="http://code.google.com/p/kyua/issues/detail?id=17"&gt;issue 17&lt;/a&gt; has been fixed!&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Kyua now captures common termination signals (such as SIGINT) and exits in a controlled manner. What this means is that Kyua will now kill any active test programs and clean up any existing work directories before exiting. What this also means is that &lt;a href="http://code.google.com/p/kyua/issues/detail?id=4"&gt;issue 4&lt;/a&gt; is fixed.&lt;/li&gt;&lt;/ul&gt;To increase amusements, a little FYI: the above points have never worked correctly in ATF, and the codebase of ATF makes it extremely hard to implement them right. I have to confess that it has been tricky to implement the above in Kyua as well, but I feel much more confident in that the implementation works well. Of course, there may be some corner cases left... but, all in all, it's more robust and easier to manage.&lt;br /&gt;&lt;br /&gt;The list of &lt;a href="http://code.google.com/p/kyua/issues/list?can=2&amp;amp;q=Milestone%3DRelease0.1+&amp;amp;colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&amp;amp;cells=tiles"&gt;pending tasks for 0.1&lt;/a&gt; shortens!&lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7087754596598489612?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7087754596598489612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7087754596598489612' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7087754596598489612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7087754596598489612'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/06/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4593224929352397182</id><published>2011-05-29T15:00:00.005-04:00</published><updated>2011-05-29T15:00:00.796-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Some cool stuff this week, albeit not large-scale:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Implemented the &lt;tt&gt;--variable&lt;/tt&gt; flag in the &lt;tt&gt;test&lt;/tt&gt; command.  This flag, which can be specified multiple times, allows a user to override any configuration variable (be it a built-in or a test-suite variable) from the command line.  This is actually the same as &lt;tt&gt;atf-run&lt;/tt&gt;'s &lt;tt&gt;-v&lt;/tt&gt; flag, but with a clear separation between built-in configuration settings and test-suite specific settings.&lt;/li&gt;&lt;li&gt;Added support for several environment variables to allow users (and tests) to override built-in paths.  I can't imagine right now any legitimate use for these variables, but hardcoded values are bad in general, &lt;tt&gt;atf-run&lt;/tt&gt; provided these same variables, and these variables are very handy for testing purposes.&lt;/li&gt;&lt;li&gt;Added support for the new &lt;tt&gt;require.files&lt;/tt&gt; test-case metadata property to both ATF and Kyua.  This new property allows tests to specify a set of files that they require in order to run, and is useful for those tests that can't run before &lt;tt&gt;make install&lt;/tt&gt; is executed.&lt;br /&gt;&lt;/ul&gt;The functionality planned for the 0.1 release is now pretty much complete.  There is still a few rough edges to clean, some documentation to write, and some little features to implement/fix.  See the &lt;a href="http://code.google.com/p/kyua/issues/list?can=2&amp;q=Milestone%3DRelease0.1+&amp;colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&amp;cells=tiles"&gt;open bugs for 0.1&lt;/a&gt; to get an idea of the remaining tasks.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4593224929352397182?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4593224929352397182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4593224929352397182' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4593224929352397182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4593224929352397182'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/05/kyua-weekly-status-report_29.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-309580888965514963</id><published>2011-05-22T18:30:00.000-04:00</published><updated>2011-05-22T18:30:46.205-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>This week:&lt;div&gt;&lt;ul&gt;&lt;li&gt;Cleaned up the internal code of the "list" command and added a few unit tests.&lt;/li&gt;&lt;li&gt;Added integration tests for the "test" command that focus mostly on the behavior of the "test" command itself. There is still a need for full integration tests that validate the execution of the test cases themselves and their cleanup, and these will be tricky to write.&lt;/li&gt;&lt;li&gt;Changed atf-c, atf-c++ and atf-sh to show a warning when a test program is run by hand. Users should really be using atf-run to execute the tests, or otherwise things like isolation or timeouts will not work (and they'll conclude that atf is broken!).&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-309580888965514963?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/309580888965514963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=309580888965514963' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/309580888965514963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/309580888965514963'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/05/kyua-weekly-status-report_22.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7943391064531556844</id><published>2011-05-22T07:01:00.000-04:00</published><updated>2011-05-22T07:01:30.003-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>Joining the Board of Directors of The NetBSD Foundation</title><content type='html'>Dear readers,&lt;br /&gt;&lt;br /&gt;It is a great pleasure for me to announce that I have just joined the Board of Directors of &lt;a href="http://www.netbsd.org/foundation/"&gt;The NetBSD Foundation&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If you are curious about how this all happened, here it goes: as described in the &lt;a href="http://www.netbsd.org/foundation/board-election-procedure.html"&gt;election procedure&lt;/a&gt;, someone who I don't know nominated me back in November of 2010 to become part of the new board composition. After the Nomination&amp;nbsp;Committee made their way through the long list of nominees, interviews and deliberation, they proposed a slate for the new members of the board. This slate included two people who were renewing their previous term (tron@ and reed@) and two new members (spz@ and jmmv@) to replace the two members stepping down (agc@ and david@). The final approval of the proposed slate happened in April 2011 and, yesterday, it became official.&lt;br /&gt;&lt;br /&gt;Looking back, I can't believe it has been already ~10 years since I first started using NetBSD. Ah, those were the times of 1.5. My responsibilities within the project have shifted a lot during this time, ranging from the maintenance of GNOME and several web site tasks, the development of the testing framework (which is still ongoing today), and, from today, to my new duties within the board.&lt;br /&gt;&lt;br /&gt;I'm looking forward to working on this new area of the project and I hope to meet the requirements of such position. The two members being replaced will be missed, and keeping up to the high bar they left behind will be tough. That said, I hope spz@ and I will be able to meet the expectations.&lt;br /&gt;&lt;br /&gt;If you have any ideas or concerns regarding the direction of &lt;a href="http://www.netbsd.org/"&gt;The NetBSD Project&lt;/a&gt;, don't hesitate to send them to the board@!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7943391064531556844?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7943391064531556844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7943391064531556844' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7943391064531556844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7943391064531556844'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/05/joining-board-of-directors-of-netbsd.html' title='Joining the Board of Directors of The NetBSD Foundation'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7861827804401724076</id><published>2011-05-16T16:07:00.000-04:00</published><updated>2011-05-16T16:07:20.976-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='conference'/><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report, BSDCan 2011 edition</title><content type='html'>I spent past week in Ottawa, Canada, attending the &lt;a href="http://www.bsdcan.org/2011/"&gt;BSDCan 2011&lt;/a&gt; conference. The conference was composed of lots of interesting content and hosted many influential and insightful BSD developers. While the NetBSD presence was very reduced, I could have some valuable talks with both NetBSD and FreeBSD developers.&lt;br /&gt;&lt;br /&gt;Anyway. As part of BSDCan 2011, I gave a talk titled "&lt;a href="http://www.bsdcan.org/2011/schedule/events/223.en.html"&gt;Automated testing in NetBSD: past, present and future&lt;/a&gt;". The talk focused on explaining what led to the development of ATF in the context of NetBSD, what related technologies exist in NetBSD (&lt;a href="http://www.netbsd.org/docs/puffs/rump.html"&gt;rump&lt;/a&gt;, &lt;a href="http://www.gson.org/netbsd/anita/"&gt;anita&lt;/a&gt;&amp;nbsp;and &lt;a href="http://releng.netbsd.org/test-results.html"&gt;dashboards&lt;/a&gt;), what ATF's shortcomings are and how Kyua plans to resolve them. (Video coming soon, I hope.)&lt;br /&gt;&lt;br /&gt;The talk was later followed by several questions and off-session conversations about testing in general in BSDs. Among these, I gathered a few random ideas / feelings:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The POSIX 1003.3 standard defines the particular results a test can emit (see the &lt;a href="http://www.delorie.com/gnu/docs/dejagnu/dejagnu_6.html"&gt;corresponding DejaGnu documentation&lt;/a&gt;). Both ATF and Kyua already implement all the results defined in the standard, but they use different names and extend the standard with many extra results. Given that the standard does not define useful concepts like "expected failures", an idea that came up is to provide a flag to force POSIX compliance at the cost of being less useful. Why? Just for the sake of saying that Kyua conforms to this standard.&lt;/li&gt;&lt;li&gt;The audience seemed to like the idea of a "tests results store" quite a bit, and the sound of SQLite for the implementation was not bullied. This is something I'm eager to work on, but not before I publish a 0.1 release.&lt;/li&gt;&lt;li&gt;I highlighted the possibility of allowing Kyua to run "foreign" test programs so that we could integrate the results into the database. This could be useful to run tests for which we (*BSD) have no control (e.g. gcc) in an integrated manner. The idea was not bullied by anyone either.&lt;/li&gt;&lt;li&gt;FreeBSD has already been looking at ATF / Kyua and they are open to collaboration.&lt;/li&gt;&lt;li&gt;OpenBSD won't import any new C++ code, and adding C-based tests to the tree while relegating the C++ runtime to the ports is not an option. Somehow I expected this.&lt;/li&gt;&lt;li&gt;Junos (the FreeBSD-based operating system from Jupiter Networks) recently imported ATF and they are happy with it so far. Yay!&lt;/li&gt;&lt;li&gt;Would be nice to have a feature to run tests remotely after, maybe, deploying a single particular test and its dependencies. This is gonna be tricky and not in my current immediate plans.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Other than that, I had little time to do some coding:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Fixed a problem in which both ATF and Kyua were not correctly resetting the timezone of the executed tests. I only found this because, after arriving in Canada, some Kyua tests would start to fail. (Yes, the fix is in both code bases!)&lt;/li&gt;&lt;li&gt;Added some support to capture deadly signals that terminate Kyua so that Kyua can print an informational message stating that something went wrong and which log file contains more information. &lt;a href="http://code.google.com/p/kyua/source/detail?r=121"&gt;See r121&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;That's it folks! Thanks to those attending the conference and, in particular, to those that came to my talk :-)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7861827804401724076?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7861827804401724076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7861827804401724076' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7861827804401724076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7861827804401724076'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/05/kyua-weekly-status-report-bsdcan-2011.html' title='Kyua: Weekly status report, BSDCan 2011 edition'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4792875439475409134</id><published>2011-05-08T17:22:00.000-04:00</published><updated>2011-05-08T17:22:58.661-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Unfortunately, no progress whatsoever this week :-( Too busy at work and preparing my upcoming trips. Time to fly to &lt;a href="http://www.bsdcan.org/2011/"&gt;BSDCan 2011&lt;/a&gt; tomorrow.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4792875439475409134?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4792875439475409134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4792875439475409134' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4792875439475409134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4792875439475409134'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/05/kyua-weekly-status-report_08.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2891918795525515491</id><published>2011-05-01T11:59:00.000-04:00</published><updated>2011-05-01T11:59:27.975-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Unfortunately, I have had no time for coding this week. The only things I could do were:&lt;div&gt;&lt;ul&gt;&lt;li&gt;Fixed a few build problems on NetBSD introduced during past week's changes.&lt;/li&gt;&lt;li&gt;Built Kyua and ran a few tests on NetBSD/macppc (just for the joy of it).&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Coding has been eclipsed by the preparation of my presentation for BSDCan 2011;&amp;nbsp;at this point, this has priority over any code changes. I'd argue that preparing the presentation is also part of the project, so some time has been invested ;-)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;More next week, hopefully, but I don't expect being able to do any big code improvements until after BSDCan.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2891918795525515491?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2891918795525515491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2891918795525515491' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2891918795525515491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2891918795525515491'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/05/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-635763632555762853</id><published>2011-04-30T05:29:00.000-04:00</published><updated>2011-04-30T05:29:43.300-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Use explicit conditionals</title><content type='html'>In C — or, for that matter, several other languages such as Python or C++ — most native types can be coerced to a boolean type: expressions that deliver integers, pointers or characters are automatically treated as boolean values whenever needed. For example: non-zero integer expression and non-NULL pointers evaluate to true whereas zero or NULL evaluate to false.&lt;br /&gt;&lt;br /&gt;Many programmers take advantage of this fact by stating their conditionals like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;void func(const int in) {&lt;br /&gt;    if (in) {&lt;br /&gt;        ... do something when in != 0 ...&lt;br /&gt;    } else {&lt;br /&gt;        ... do something else when in == 0 ...&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;... or even do something like:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;bool func(const struct mystruct *ptr) {&lt;br /&gt;    int out = calculate_out(in);&lt;br /&gt;&lt;br /&gt;    ... do something more with out ...&lt;br /&gt;&lt;br /&gt;    return out;  // The return type is bool though; is this ok?&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;... but such idioms are sloppy and can introduce confusion or bugs. Yes, things work in many cases, but "work" is not a synonym for "good" ;-)&lt;br /&gt;&lt;br /&gt;Taking advantage of coercions (automatic type conversions) typically makes the code harder to follow. In statically-typed languages, whenever you define a variable to be of a particular type, you should adhere to said type by all means so that no confusion is possible. Conceptually, an integer is not a boolean and therefore it should not be treated as such. But this is just a matter of style.&lt;br /&gt;&lt;br /&gt;On the other hand, the automatic conversions can lead to hidden bugs; for example, in the second function above, did we really want to convert the "out" value to a boolean or was that a mistake? &amp;nbsp;This is not so much a matter of style but a matter of careful programming, and having as much state as possible "in your face" can help prevent these kind of trivial errors.&lt;br /&gt;&lt;br /&gt;In contrast, one would argue that having to provide explicit checks or casts on every expression is a waste of time. But keep in mind that code is supposed to be written once and read many times. Anything you can do to communicate your &lt;i&gt;intent&lt;/i&gt; to the reader will surely be appreciated.&lt;br /&gt;&lt;br /&gt;Disclaimer: the above is my personal opinion only. Not following the style above should have no implications on the resulting binary code. (Wow, this post had been sitting as a draft around here for a too long time.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-635763632555762853?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/635763632555762853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=635763632555762853' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/635763632555762853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/635763632555762853'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/04/use-explicit-conditionals.html' title='Use explicit conditionals'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7729948007117435448</id><published>2011-04-24T14:15:00.000-04:00</published><updated>2011-04-24T14:15:50.381-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Ouch; I'm exhausted. I just finished a multi-hour hacking session to get the implementation of the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;list&lt;/span&gt;&amp;nbsp;subcommand in control. It is now in a very nice user-facing shape, although its code deserves a little bit of house cleaning (coming soon).&lt;br /&gt;&lt;br /&gt;Anyway, this week's progress:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Added the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;kyuaify.sh&lt;/span&gt; script. This little tool takes a test suite (say, NetBSD's &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/usr/tests&lt;/span&gt; directory) and converts all its &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Atffile&lt;/span&gt;s into &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Kyuafile&lt;/span&gt;s. The tool is no sophisticated at all; in fact, it is a pretty simple script that I haven't tested with any other test suites so far. See the &lt;a href="https://groups.google.com/group/kyua-discuss/browse_thread/thread/d0077d8992a04bf0"&gt;announcement of kyuaify&lt;/a&gt; for some extra details.&lt;/li&gt;&lt;li&gt;Added logging support for the Lua code and changed the Lua modules to spit some logging information while processing Kyuafiles and configuration files.&lt;/li&gt;&lt;li&gt;Added a mechanism in the user interface module to consistently print informational, warning and error messages.&lt;/li&gt;&lt;li&gt;Implemented proper test filtering (after several iterations). What does proper mean? Well, for starters, test filters are always relative to the test suite's root (although we already saw this in last week's report). But the most important thing is that the filters are now validated: nice, user-friendly errors will be reported when the collection of tests is non-disjoint, when it includes duplicate names or when any of the provided filters does not match any test case. I really need to document the rationale of these in the manual, but for now the &lt;a href="http://code.google.com/p/kyua/source/detail?r=118"&gt;r118 commit message&lt;/a&gt; includes a few details.&lt;/li&gt;&lt;li&gt;Drafted some notes for the BSDCan 2011 conference. I am quite tempted to reuse parts of the presentation from NYCBSDCon 2010, but I really want to give more emphasis on Kyua this time. In case you don't know, Kyua was first announced in NYCBSDCon 2010 and it was still a very immature project. The project has changed a lot since then.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;The wishful plan for next week is to clean up the internals of the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;list&lt;/span&gt;&amp;nbsp;command (by refactoring and adding unit tests) and implement preliminary integration tests for the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;test&lt;/span&gt;&amp;nbsp;subcommand. The latter scares me quite a bit. But... hmm... I guess preparing the presentation for BSDCan 2011 has priority.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7729948007117435448?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7729948007117435448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7729948007117435448' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7729948007117435448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7729948007117435448'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/04/kyua-weekly-status-report_24.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8382380056617644817</id><published>2011-04-17T15:29:00.000-04:00</published><updated>2011-04-17T15:29:49.823-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>&lt;div&gt;This week started easy:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Added integration tests for the &lt;b&gt;about&lt;/b&gt; and &lt;b&gt;help&lt;/b&gt; subcommands. These were pretty easy to do.&lt;/li&gt;&lt;li&gt;Added integration tests for the &lt;b&gt;list&lt;/b&gt; subcommand. I initially added these tests as &lt;i&gt;expected failures&lt;/i&gt; to reason about the appearance and behavior of this command from the point of view of the user before actually working on the code... and I am still writing such code to make these tests pass!&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;This is where things got a bit awry. Polishing the behavior of the list command so that its interface is consistent among all flag and argument combinations is tricky and non-trivial. I ended up having to change code deep down in the source tree to implement missing features and to change existing bits and pieces:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Implemented support to print all test case properties, not only the user-specific ones. The properties recognized by the runtime engine are stored as individual arguments of a structure, so these required some externalization code.&lt;/li&gt;&lt;li&gt;Implemented "test case filtering". This allows users to select what tests to run on the command line at the test case granularity. For example, &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;foo/bar&lt;/span&gt; selects all tests in a subdirectory if &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;bar&lt;/span&gt; is a directory, or all the tests in the &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;bar&lt;/span&gt; test program if it is a binary. But what is new (read: not found in ATF) is that you can even do &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;foo/bar:test-1&lt;/span&gt; where &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;test-1&lt;/span&gt; is the name of a test case within the foo/bar test program. I've been silently wishing for this feature to be available in ATF because it shortens the build/test/edit cycle, but it was not easy to add.&lt;/li&gt;&lt;li&gt;Changed the internal representation of test suites to ensure all test program names are relative to the root of the test suite. The root of the test suite is considered to be the directory in which the top-level Kyuafile lives (&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;/usr/tests/&lt;/span&gt; in NetBSD). The whole point of doing this is to provide some consistency to the filters when the user decides to execute tests that are not in the current directory. For example, the following are now equivalent:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ cd /usr/tests &amp;amp;&amp;amp; kyua list fs/tmpfs&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ kyua list -k /usr/tests/Kyuafile fs/tmpfs&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;The plans for the upcoming week are to finish with the clean up of the list command (which involves adding proper error reporting, refactoring of the command module and addition of unit tests) and start cleaning up the test command.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Also, remember that &lt;a href="http://www.bsdcan.org/2011/"&gt;BSDCan 2011&lt;/a&gt; is now around the corner and that &lt;a href="http://www.bsdcan.org/2011/schedule/events/223.en.html"&gt;I will be talking about ATF, Kyua and NetBSD&lt;/a&gt; in it! &amp;nbsp;My plan was to have a kyua-cli-0.1 release by the time of the conference, although this will be tricky to achieve...&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8382380056617644817?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8382380056617644817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8382380056617644817' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8382380056617644817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8382380056617644817'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/04/kyua-weekly-status-report_17.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6675497401743036831</id><published>2011-04-10T15:00:00.000-04:00</published><updated>2011-04-10T15:00:00.857-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>Few things worth mentioning this week as reviewing Summer of Code student applications has taken priority. The good thing is that there are several strong applications for NetBSD; the bad thing is that none relate directly to testing. Anyway, the work this week:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Added a pkg-config file for atf-sh as well as an Autoconf macro to detect its presence. This is needed by Kyua to easily find atf-sh. (Yes, I know: this is an abuse of pkg-config, but it works pretty well and is consistent with atf-c and atf-c++.)&lt;/li&gt;&lt;li&gt;Implemented basic integration tests for Kyua in &lt;a href="http://code.google.com/p/kyua/source/detail?r=98"&gt;r98&lt;/a&gt;&amp;nbsp;using atf-sh. These tests are still very simple but provide a placeholder into which new tests will be plugged. Having good integration test coverage is key in preparation for a 0.1 release. Oh, and by the way, this revision has bumped the number of tests to 601, crossing the 600 barrier :-)&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;That's pretty much it. Now, back to attempting to fix my home server as a fresh installation of NetBSD/macppc has decided to not boot any more. &amp;nbsp;(Yes, this has blocked most of my weekend...)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6675497401743036831?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6675497401743036831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=6675497401743036831' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6675497401743036831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6675497401743036831'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/04/kyua-weekly-status-report_10.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-3051235737463467147</id><published>2011-04-03T15:00:00.000-04:00</published><updated>2011-04-03T15:00:01.191-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>This week's work has been quite active on the ATF front but not so much in the Kyua one. I keep being incredibly busy on the weekends (read: traveling!) so it's hard to get any serious development work done.&lt;br /&gt;&lt;br /&gt;What has happened?&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Finally tracked down and fixed some random atf-run crashes that had been hunting the NetBSD test suite for months (see &lt;a href="http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=44176"&gt;PR bin/44176&lt;/a&gt;). The fix is in reality an ugly workaround for the fact that a work directory cannot be considered "stable" even after the test case terminates. There may be dying processes around that touch the work directory contents, and the cleanup code in atf-run was not coping well with those. As it turns out, this problem also exists in Kyua (even though it's not as pronounced because arbitrary failures when running a test case do not crash the runtime engine) so I filed &lt;a href="http://code.google.com/p/kyua/issues/detail?id=17"&gt;issue 17&lt;/a&gt; to address it.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.netbsd.org/~jmmv/atf/news.html#20110331-atf-0-13-released"&gt;Released ATF 0.13&lt;/a&gt; and imported it both to NetBSD-current and pkgsrc. As a side note, Kyua requires the new features in this release, so putting it out there is a requirement to release Kyua 0.1. This new release does not have a big effect on NetBSD though, because the copy of ATF in NetBSD has been constantly receiving cherry-picks of the upstream fixes.&lt;/li&gt;&lt;li&gt;Replaced several TODO items in the Kyua code with proper calls to the logging subsystem. These TODO items were referring to conditions in the code that should not happen, but for which we cannot do any proper recovery (like errors in a destructor). Sure, these could be better signaled as an assertion... but these code paths can be triggered in extremely-tricky conditions and having Kyua crash because of them is not nice (particularly when the side-effects of executing that code paths are non-critical).&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;So, in retrospect, I have fulfilled the goal set past week of releasing ATF 0.13, but I haven't got to the addition of integration tests. Oh well... let's see if this upcoming week provides more spare time.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-3051235737463467147?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/3051235737463467147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=3051235737463467147' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3051235737463467147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3051235737463467147'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/04/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1674122557081366774</id><published>2011-03-27T15:00:00.005-04:00</published><updated>2011-03-27T15:00:01.997-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>This has been a slow week. In the &lt;a href="http://blog.julipedia.org/2011/03/kyua-weekly-status-report.html"&gt;previous report&lt;/a&gt;, I set the goal of&amp;nbsp;getting Kyua to run the NetBSD test suite accurately (i.e. to report the same results as atf-run), and this has been accomplished. Actually, the changes required in Kyua to make this happen were minimal, but I got side-tracked fixing issues in NetBSD itself (both in the test suite and in the kernel!). So, the things done:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Fixed Kyua to correctly kill any dangling subprocesses of a test case and thus match the behavior of atf-run. This was the only change required to make &lt;a href="http://code.google.com/p/kyua/issues/detail?id=16"&gt;issue 16&lt;/a&gt; happen: i.e. to get Kyua to report the same results as atf-run for the NetBSD test suite.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Based on a suggestion from Antti Kantee, an alternative way to handle this would be to not kill any processes and just report the test case as broken if it fails to clean itself up. The rationale being that the runtime engine can kill dangling subprocesses in 99% of the occasions, but not always. The exception are those subprocesses that change their process group. It'd be better to make all cleanups explicit instead of hiding this corner case, as it can lead to confusion. Addressing this will have to wait though, as it is a pretty invasive change.&lt;/li&gt;&lt;li&gt;Before closing issue 16, I want to implement some integration tests for Kyua to ensure that the whole system behaves as we expect (which is what the NetBSD test suite is currently doing implicitly).&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Kyua is pickier than atf-run: if a cleanup routine of a test case fails or crashes, Kyua will (correctly) report the test case as broken while atf-run will silently ignore this situation. Some NetBSD tests had crashing cleanup parts, so I fixed them.&lt;/li&gt;&lt;li&gt;Some test programs in NetBSD were leaving unkilled subprocesses behind. These subprocesses are daemons and thus fall out of the scope of what Kyua can detect and kill during the cleanup phase. I mistakenly tracked down the problem to rump, but Antti Kantee kindly &lt;a href="http://mail-index.netbsd.org/tech-kern/2011/03/23/msg010153.html"&gt;found the real problem&lt;/a&gt; in the kernel (not in rump!).&lt;/li&gt;&lt;li&gt;As a side effect of processes being left behind, I &lt;a href="http://mail-index.netbsd.org/tech-userlevel/2011/03/23/msg004775.html"&gt;extended the functionality of pidfile(3)&lt;/a&gt; and implemented pid file support in bozohttpd. &amp;nbsp;This is to make the tests that spawn a bozohttpd in the background more robust, by giving them a way to forcibly kill the server during cleanup.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;These changes are still under review and not committed yet.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div&gt;For the upcoming week, I plan to add some basic integration tests to Kyua and release ATF 0.13. I've been running a NetBSD system with the latest ATF code integrated for a while (because Kyua requires it) and things have been working well.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1674122557081366774?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1674122557081366774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1674122557081366774' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1674122557081366774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1674122557081366774'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/03/kyua-weekly-status-report_27.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2229167293615263320</id><published>2011-03-20T11:58:00.007-04:00</published><updated>2011-03-20T12:58:37.080-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='report'/><title type='text'>Kyua: Weekly status report</title><content type='html'>These days, I find myself talking about &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt; to "many" people.  In particular, whenever a new feature request for &lt;a href="http://www.netbsd.org/%7Ejmmv/atf/"&gt;ATF&lt;/a&gt; comes in, I promise the requester that the feature will be addressed as part of Kyua.  However, I can imagine that this behavior leaves the requester with mixed feelings: it is nice that the feature will be implemented but, at the same time, it is very hard to know when because the web site of Kyua does not provide many details about its current status.&lt;br /&gt;&lt;br /&gt;In an attempt to give Kyua some more visibility, I will start posting weekly activity reports in this blog.  These reports will also include any work done on the ATF front, as the two projects are highly related at this point.  I write these reports regularly at work and I feel like it is a pretty good habit: every week, you have to spend some time thinking about what you did for the project and you feel guilty if the list of tasks is ~zero ;-)  It also, as I said, gives more visibility to the work being done so that outsiders know that the project is not being ignored.&lt;br /&gt;&lt;br /&gt;Before starting with what has happened this week, a bit of context.  I have been traveling like crazy and hosting guests over for the last 2 months.  This has given me virtually no time to work on Kyua but, finally, I have got a chance to do some work this past week.&lt;br /&gt;&lt;br /&gt;So, what are the news?&lt;ul&gt;&lt;li&gt;Implemented the &lt;tt&gt;--loglevel&lt;/tt&gt; command line flag, which closes &lt;a href="http://www.google.com/url?sa=D&amp;amp;q=http://code.google.com/p/kyua/issues/detail?id=14"&gt;issue 14&lt;/a&gt;.  Kyua now generates run-time logs of its internal activity to aid in postmortem debugging and this flag allows the user to control the verbosity of such logs.&lt;/li&gt;&lt;li&gt;Antti Kantee hacked support for atf-run in the NetBSD source tree to dump a stack trace of any crashing test program.  I have backported this code to the upstream ATF code and filed &lt;a href="http://www.google.com/url?sa=D&amp;amp;q=http://code.google.com/p/kyua/issues/detail?id=15"&gt;issue 15&lt;/a&gt; to implement this same functionality in Kyua.&lt;/li&gt;&lt;li&gt;Fixed a hang in atf-run that made it get stuck when a test case spawned a child processes and atf-run failed to terminate it.  A quick test seems to indicate that Kyua is affected by a similar problem: it does not get stuck but it does not correctly kill the subprocesses.  The problem will be addressed as part of &lt;a href="http://www.google.com/url?sa=D&amp;amp;q=http://code.google.com/p/kyua/issues/detail?id=16"&gt;issue 16&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Oh, and by the way: Kyua will be &lt;a href="http://www.bsdcan.org/2011/schedule/events/223.en.html"&gt;presented at BSDCan 2011&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;My plans for this week are to make Kyua run the full NetBSD test suite without regressions when compared to ATF.  Basically, the results of a test run with Kyua should be exactly the same as those of a test run with ATF.  No dangling processes should be left behind.&lt;br /&gt;&lt;br /&gt;Lastly, if you are interested in these reports and other Kyua news, you can subscribe to the &lt;a href="http://blog.julipedia.org/feeds/posts/default/-/kyua"&gt;kyua label feed&lt;/a&gt; and, if you want to stay up to date with &lt;i&gt;any&lt;/i&gt; changes performed to the code, subscribe to the &lt;a href="https://groups.google.com/group/kyua-log"&gt;kyua-log&lt;/a&gt; mailing list.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2229167293615263320?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2229167293615263320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2229167293615263320' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2229167293615263320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2229167293615263320'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/03/kyua-weekly-status-report.html' title='Kyua: Weekly status report'/><author><name>Julio Merino</name><uri>https://profiles.google.com/116093576758169781959</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-X10AK3UQwAQ/AAAAAAAAAAI/AAAAAAAABUk/GjMkQdGPXrA/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4795594299098371445</id><published>2011-01-27T16:12:00.003-05:00</published><updated>2011-01-27T16:30:30.638-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='books'/><category scheme='http://www.blogger.com/atom/ns#' term='twitter'/><title type='text'>A teeny tiny review of Twitterville</title><content type='html'>After about two months, I finally finished reading Twitterville by Shel Israel (&lt;a href="http://twitter.com/#!/shelisrael"&gt;@shelisrael&lt;/a&gt;).  One of my followers (&lt;a href="http://twitter.com/#!/drio"&gt;@drio&lt;/a&gt;) &lt;a href="http://twitter.com/#!/drio/status/30728660998684674"&gt;asked for a review&lt;/a&gt; of the book, so here is my attempt to do so.&lt;br /&gt;&lt;br /&gt;But first, a quick summary: Twitterville is a book that focuses on the dynamics of Twitter.  It starts by explaining how Twitter works, but that is only a tiny introductory part of the book.  The majority of the contents explain how people and business interact with each other by means of Twitter, and it does so by providing lots of real-life stories.  The stories range from topics as diverse as businesses offering deals, to individuals raising funds for specific causes.&lt;br /&gt;&lt;br /&gt;The book is easy to read and is well structured, and as you read through it you will realize that the author had to do some major research efforts to collect all the stories that he presents.  I personally enjoyed the first half of the book a lot, but at some point I ran out of time for reading and my interest dropped.  It was hard to pick on reading again because the book becomes quite repetitive after a few chapters; just keep in mind that it is a collection of personal experiences organized by different major topics and you won't be disappointed.&lt;br /&gt;&lt;br /&gt;Twitterville has changed my view on Twitter.  I have discovered many "use cases" for Twitter that I could not imagine and, as many people do, I used to disregard Twitter as a useless "status updates" system.  Today, however, I have &lt;a href="http://blog.julipedia.org/2010/12/getting-hang-of-twitter-searches.html"&gt;set up several Twitter searches&lt;/a&gt; to monitor some topics of my interest and I engage with people that I did not know beforehand.  It kinda feels like a world-wide unorganized chat room to me... but, as the author mentions many times, the way you see and use Twitter is up to you and you alone!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4795594299098371445?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4795594299098371445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4795594299098371445' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4795594299098371445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4795594299098371445'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/01/teeny-tiny-review-of-twitterville.html' title='A teeny tiny review of Twitterville'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7241623974240538881</id><published>2011-01-17T11:09:00.002-05:00</published><updated>2011-01-17T11:31:13.974-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Injecting C++ functions into Lua</title><content type='html'>The &lt;a href="http://blog.julipedia.org/2011/01/c-interface-to-lua.html"&gt;C++ interface to Lua&lt;/a&gt; implemented in &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt; exposes a &lt;tt&gt;lua::state&lt;/tt&gt; class that wraps the lower-level &lt;tt&gt;lua_State*&lt;/tt&gt; type. This class completely hides the internal C type of Lua to ensure that all calls that affect the state go through the &lt;tt&gt;lua::state&lt;/tt&gt; class.&lt;br /&gt;&lt;br /&gt;Things get a bit messy when we want to inject native functions into the Lua environment. These functions follow the prototype represented by the &lt;tt&gt;lua_CFunction&lt;/tt&gt; type:&lt;blockquote&gt;&lt;tt&gt;typedef int (*lua_CFunction)(lua_State*);&lt;/tt&gt;&lt;/blockquote&gt;Now, let's consider this code:&lt;pre&gt;int&lt;br /&gt;awesome_native_function(lua_State* state)&lt;br /&gt;{&lt;br /&gt;    // Uh, we have access to s, so we bypass the lua::state!&lt;br /&gt;    ... do something nasty ...&lt;br /&gt;&lt;br /&gt;    // Oh, and we can throw an exception here...&lt;br /&gt;    //with bad consequences.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;setup(...)&lt;br /&gt;{&lt;br /&gt;    lua::state state;&lt;br /&gt;    state.push_c_function(awesome_native_function);&lt;br /&gt;    state.set_global("myfunc");&lt;br /&gt;    ... run some script ...&lt;br /&gt;}&lt;/pre&gt;The fact that we must pass a &lt;tt&gt;lua_CFunction&lt;/tt&gt; prototype to the &lt;tt&gt;lua_pushcfunction&lt;/tt&gt; object means that such function must have access to the raw &lt;tt&gt;lua_State*&lt;/tt&gt; pointer... which we want to avoid.&lt;br /&gt;&lt;br /&gt;What we really want is the caller code to define a function such as:&lt;blockquote&gt;&lt;tt&gt;typedef int (*cxx_function)(lua::state&amp;)&lt;/tt&gt;&lt;/blockquote&gt;In an ideal world, the &lt;tt&gt;lua::state&lt;/tt&gt; class would implement a &lt;tt&gt;push_cxx_function&lt;/tt&gt; that took a &lt;tt&gt;cxx_function&lt;/tt&gt;, generated a thin C wrapper and injected such generated wrapper into Lua.  Unfortunately, we are not in an ideal world: C++ does not have high-order functions and thus the "generate a wrapper function" part of the previous proposal does not really work.&lt;br /&gt;&lt;br /&gt;What we can do instead, though, is to make the creation of C wrappers for these C++ functions trivial. And this is what &lt;a href="http://code.google.com/p/kyua/source/detail?r=42"&gt;r42&lt;/a&gt; did.  The approach I took is similar to this overly-simplified (and broken) example:&lt;pre&gt;template&amp;lt; cxx_function Function &amp;gt;&lt;br /&gt;int&lt;br /&gt;wrap_cxx_function(lua_State* state)&lt;br /&gt;{&lt;br /&gt;    try {&lt;br /&gt;        lua::state state_wrapper(state);&lt;br /&gt;        return Function(state_wrapper);&lt;br /&gt;    } catch (...) {&lt;br /&gt;        luaL_error(state, "Geez, don't go into C's land!");&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;This template wrapper takes a &lt;tt&gt;cxx_function&lt;/tt&gt; object and generates a corresponding C function &lt;i&gt;at compile time&lt;/i&gt;. This wrapper function ensures that C++ state does not propagate into the C world, as that often has catastrophical consequences. (Due to language limitations, the input function must have external linkage.  So no, it cannot be static.)&lt;br /&gt;&lt;br /&gt;As a result, we can rewrite our original snippet as:&lt;pre&gt;int&lt;br /&gt;awesome_native_function(lua::state&amp; state)&lt;br /&gt;{&lt;br /&gt;    // See, we cannot access lua_State* now.&lt;br /&gt;&lt;br /&gt;    ... do something ...&lt;br /&gt;    throw std::runtime_error("And we can even do this!");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;setup(...)&lt;br /&gt;{&lt;br /&gt;    lua::state state;&lt;br /&gt;    state.push_c_function(&lt;br /&gt;        wrap_cxx_function&lt; awesome_native_function &gt;);&lt;br /&gt;    state.set_global("myfunc");&lt;br /&gt;    ... run some script ...&lt;br /&gt;}&lt;/pre&gt;Neat? I think so, but maybe not so much. I'm pretty sure there are cooler ways of achieving the above purpose in a cleaner way, but this one works nicely and has few overhead.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7241623974240538881?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7241623974240538881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7241623974240538881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7241623974240538881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7241623974240538881'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/01/injecting-c-functions-into-lua.html' title='Injecting C++ functions into Lua'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1239137422252979300</id><published>2011-01-14T03:04:00.004-05:00</published><updated>2011-01-14T04:11:02.150-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Error handling in Lua: the Kyua approach</title><content type='html'>About a week ago, I detailed the different approaches I encountered to &lt;a href="http://blog.julipedia.org/2011/01/error-handling-in-lua.html"&gt;deal with errors raised by the Lua C API&lt;/a&gt;. Later, I announced the &lt;a href="http://blog.julipedia.org/2011/01/c-interface-to-lua.html"&gt;new C++ interface for Lua&lt;/a&gt; implemented within &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt;. And today, I would like to talk about the specific mechanism I implemented in this library to deal with the Lua errors.&lt;br /&gt;&lt;br /&gt;The first thing to keep in mind is that the whole purpose of Lua in the context of Kyua is to parse configuration files. This is an infrequent operation, so &lt;i&gt;high performance does not matter&lt;/i&gt;: it is more valuable to me to be able to write robust algorithms fast than to have them run at optimal speed. The other key point to consider is that I want Kyua to be able to use prebuilt Lua libraries, which are built as C binaries.&lt;br /&gt;&lt;br /&gt;The approach I took is to wrap every single unsafe Lua C API call in a "thin" (FSVO thin depending on the case) wrapper that gets called by &lt;tt&gt;lua_pcall&lt;/tt&gt;. Anything that runs inside the wrapper is safe to Lua errors, as they are caught and safely reported to the caller.&lt;br /&gt;&lt;br /&gt;Lets examine how this works by taking a look at an example: the wrapping of &lt;tt&gt;lua_getglobal&lt;/tt&gt;. We have the following code (copy pasted from the &lt;a href="http://code.google.com/p/kyua/source/browse/trunk/kyua-cli/utils/lua/wrap.cpp?spec=svn39&amp;r=39"&gt;utils/lua/wrap.cpp&lt;/a&gt; file but hand-edited for publishing here):&lt;pre&gt;static int&lt;br /&gt;protected_getglobal(lua_State* state)&lt;br /&gt;{&lt;br /&gt;    lua_getglobal(state, lua_tostring(state, -1));&lt;br /&gt;    return 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;lua::state::get_global(const std::string&amp; name)&lt;br /&gt;{&lt;br /&gt;    lua_pushcfunction(_pimpl-&gt;lua_state, protected_getglobal);&lt;br /&gt;    lua_pushstring(_pimpl-&gt;lua_state, name.c_str());&lt;br /&gt;    if (lua_pcall(_pimpl-&gt;lua_state, 1, 1, 0) != 0)&lt;br /&gt;        throw lua::api_error::from_stack(_pimpl-&gt;lua_state,&lt;br /&gt;            "lua_getglobal");&lt;br /&gt;}&lt;/pre&gt;The &lt;tt&gt;state::get_global&lt;/tt&gt; method is my public wrapper for the &lt;tt&gt;lua_getglobal&lt;/tt&gt; Lua C API call. This wrapper first prepares the Lua stack by pushing the address of the C function to call and its parameters and then issues a &lt;tt&gt;lua_pcall&lt;/tt&gt; call that executes the C function in a Lua protected environment.&lt;br /&gt;&lt;br /&gt;In this case, the argument preparation for &lt;tt&gt;protected_getglobal&lt;/tt&gt; is trivial because the &lt;tt&gt;lua_getglobal&lt;/tt&gt; call does not require access to any preexisting values on the Lua stack. Things get much trickier when that happens as in the case of the &lt;tt&gt;lua_getglobal&lt;/tt&gt; wrapper. I'll leave understanding how to do this as an exercise to the reader (but you can cheat by looking at &lt;a href="http://code.google.com/p/kyua/source/browse/trunk/kyua-cli/utils/lua/wrap.cpp?spec=svn39&amp;r=39#154"&gt;line 154&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;Anyway. The above looks all very nice and safe and the &lt;a href="http://code.google.com/p/kyua/source/browse/trunk/kyua-cli/utils/lua/wrap_test.cpp?spec=svn39&amp;r=39#112"&gt;tests for the state::get_global function&lt;/a&gt;, even the ones that intentionally cause a failure, all work fine. So we are good, right? &lt;i&gt;Nope!&lt;/i&gt; Unfortunately, the code above is not fully safe to Lua errors.&lt;br /&gt;&lt;br /&gt;In order to prepare the &lt;tt&gt;lua_pcall&lt;/tt&gt; execution, the code must push values on the stack. As it turns out, both &lt;tt&gt;lua_pushcfunction&lt;/tt&gt; and &lt;tt&gt;lua_pushstring&lt;/tt&gt; &lt;i&gt;can&lt;/i&gt; fail if they run out of memory (OOM). Such failure would of course be captured inside a protected environment... but we have a little chicken'n'egg problem here. That said, OOM failures are rare so I'm going to leverage this fact and not worry about it.  (Note to self: install a &lt;tt&gt;lua_atpanic&lt;/tt&gt; handler to complain loudly if that ever happens.)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Addendum&lt;/b&gt;: Bundling Lua within my program and building it as a C++ binary with exception reporting enabled in &lt;tt&gt;luaconf.h&lt;/tt&gt; would magically solve all my issues. I know. But I don't fancy the idea of bundling the library into my source tree for a variety of reasons.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1239137422252979300?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1239137422252979300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1239137422252979300' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1239137422252979300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1239137422252979300'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/01/error-handling-in-lua-kyua-approach.html' title='Error handling in Lua: the Kyua approach'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6364788218543929473</id><published>2011-01-08T08:17:00.005-05:00</published><updated>2011-01-08T08:28:50.006-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>C++ interface to Lua for Kyua</title><content type='html'>Finally! After two weeks of holidays work, I have finally been able to submit &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt;'s &lt;a href="http://code.google.com/p/kyua/source/detail?r=39"&gt;r39&lt;/a&gt;: a generic library that implements a C++ interface to &lt;a href="http://www.lua.org/"&gt;Lua&lt;/a&gt;. The code is hosted in the &lt;tt&gt;&lt;a href="http://code.google.com/p/kyua/source/browse/#svn%2Ftrunk%2Fkyua-cli%2Futils%2Flua"&gt;utils/lua/&lt;/a&gt;&lt;/tt&gt; subdirectory.&lt;br /&gt;&lt;br /&gt;From the revision description:&lt;blockquote&gt;The utils::lua library provides thin C++ wrappers around the Lua C API to ease the interaction between C++ and Lua.  These wrappers make intensive use of RAII to prevent resource leakage, expose C++-friendly data types, report errors by means of exceptions and ensure that the Lua stack is always left untouched in the face of errors.  The library also provides a place (the operations module) to add miscellaneous utility functions built on top of the wrappers.&lt;/blockquote&gt;In other words: this code aims to decouple all details of the interaction with the Lua C API from the main code of Kyua so that the high level algorithms do not have to worry about Lua C API idiosyncrasies.&lt;br /&gt;&lt;br /&gt;Further changes to Kyua to implement the &lt;a href="http://code.google.com/p/kyua/wiki/ConfigurationDesign"&gt;new configuration system&lt;/a&gt; will follow soon as all the basic code to talk to Lua has been ironed out. Also expect some extra posts regarding the design decisions that went on this helper code and, in particular, about error reporting as mentioned in the &lt;a href="http://blog.julipedia.org/2011/01/error-handling-in-lua.html"&gt;previous post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;(Yep, Lua and Kyua sound similar. But that was never intended; promise!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6364788218543929473?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6364788218543929473/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=6364788218543929473' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6364788218543929473'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6364788218543929473'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/01/c-interface-to-lua.html' title='C++ interface to Lua for Kyua'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8550141972122584410</id><published>2011-01-07T08:01:00.004-05:00</published><updated>2011-01-07T08:46:16.736-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Error handling in Lua</title><content type='html'>Some of the methods of the Lua C API can raise errors. To get an initial idea on what these are, take a look at the &lt;a href="http://www.lua.org/manual/5.1/manual.html#3.7"&gt;Functions and Types&lt;/a&gt; section and pay attention to the third field of a function description (the one denoted by 'x' in the introduction).&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Dealing with the errors raised by these functions is tricky, not to say a nightmare. Also, the &lt;a href="http://www.lua.org/manual/5.1/manual.html#3.6"&gt;ridiculously-short documentation on this topic&lt;/a&gt; does not help. This post is dedicated to explain how these errors may be handled along with the advantages and disadvantages of each case.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Lua C API provides two modes of execution: protected and unprotected. When in protected mode, all errors caused by Lua are caught and reported to the caller in a controlled manner. When in unprotected mode, the errors just abort the execution of the calling process by default. So, one would think: just run the code in protected mode, right? Yeah, well... entering protected mode is nontrivial and it has its own particularities that make interaction with C++ problematic.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let's analyze error reporting by considering a simple example: the &lt;tt&gt;lua_gettable&lt;/tt&gt; function.  The following Lua code would error out when executed:&lt;pre&gt;my_array = nil&lt;br /&gt;return my_array["test"]&lt;/pre&gt;... which is obvious because indexing a non-table object is a mistake.  Now let's consider how this code would look like in C (modulo the &lt;tt&gt;my_array&lt;/tt&gt; assignment):&lt;pre&gt;lua_getglobal(state, "my_array");&lt;br /&gt;lua_pushstring(state, "test");&lt;br /&gt;lua_gettable(state, -2);&lt;/pre&gt;Simple, huh? Sure, but as it turns out, &lt;i&gt;any&lt;/i&gt; of the API calls (not just &lt;tt&gt;lua_gettable&lt;/tt&gt;) in this code can raise errors (I'll call them &lt;i&gt;unsafe&lt;/i&gt; functions). What this means is that, unless you run the code with a &lt;tt&gt;lua_pcall&lt;/tt&gt; wrapper, your program will simply &lt;i&gt;exit&lt;/i&gt; in the face of a Lua error. Uh, your scripting language can "crash" your host program out of your control? Not nice.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What would be nice is if each of the Lua C API unsafe functions reported an error (as a return value or whatever) and allowed the caller to decide what to do. Ideally, no state would change in the face of an error. Unfortunately, that is not the case but it is exactly what I would like to do. I am writing a C++ wrapper for Lua in the context of Kyua and fine granularity in error reporting means that automatic cleanup of resources managed by RAII is trivial.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Let's analyze the options that we have to control errors caused within the Lua C API. I will explain in a later post the one I have chosen for the wrapper in Kyua (it has to be later because I'm not settled yet!).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;b&gt;Install a panic handler&lt;/b&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Whenever Lua code runs in an unprotected environment, one can use &lt;tt&gt;lua_atpanic&lt;/tt&gt; to install a handler for errors.  The function provided by the user is executed when the error occurs and, if the panic function returns, the program exits.  To prevent exiting prematurely, one could opt for two mechanisms:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Make the panic handler raise a C++ exception.  Sounds nice, right?  Well, it does not work.  The Lua library is generally built as a C binary which means that our panic handler will be called from within a C environment.  As a result, we cannot throw an exception from our C++ handler and expect things to work: the exception won't propagate correctly from a C++ context to a C context and then back to C++.  Most likely, the program will abort as soon as we leave the C++ world and enter C to unwind the stack.&lt;/li&gt;&lt;li&gt;Use &lt;tt&gt;setjmp&lt;/tt&gt; before the call to the unsafe Lua function and recover with &lt;tt&gt;longjmp&lt;/tt&gt; from within the panic handler.  It turns out that this does work &lt;i&gt;but&lt;/i&gt; with one important caveat: the stack is completely cleared before the call to the panic handler.  As a result, this prevents the requirement of "leave the stack unmodified on failure" as is desired of any function (report errors early before changing state).&lt;/li&gt;&lt;/ul&gt;&lt;span class="Apple-style-span"&gt;&lt;b&gt;Run every single call in a protected environment&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This is doable but complex and not completely right: to do this, we need to write a C wrapper function for every unsafe API function and run it with &lt;tt&gt;lua_pcall&lt;/tt&gt;. The overhead of this approach is significant: something as simple as a call to &lt;tt&gt;lua_gettable&lt;/tt&gt; turns into several stack manipulation operations, a call to &lt;tt&gt;lua_pcall&lt;/tt&gt; and then further stack modifications to adjust the results.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Additionally, in order to prepare the call to &lt;tt&gt;lua_pcall&lt;/tt&gt;, one has to use the multiple &lt;tt&gt;lua_push*&lt;/tt&gt; functions to prepare the stack for the call. And, guess what, most of these functions that push values onto the stack can themselves fail. So... in order to prepare the environment for a safe call, we are already executing unsafe calls. (Granted, the errors in these case are only due to memory exhaustion... but still, the solution is not fully robust.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lastly, note that we cannot use &lt;tt&gt;lua_cpcall&lt;/tt&gt; because it does discard all return values of the executed function. Which means that we can't really wrap single Lua operations. (We could wrap a whole algorithm though.)&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;b&gt;Run the whole algorithm in a protected environment&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This defeats the whole purpose of the per-function wrapping.  We would need to provide a separate C/C++ function that runs all unsafe code and then call it by means of &lt;tt&gt;lua_pcall&lt;/tt&gt; (or &lt;tt&gt;lua_cpcall&lt;/tt&gt;) so that errors are captured and reported in a controlled manner.  This seems very efficient... albeit not transparent and will surely cause issues.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Why is this problematic? Errors that happen inside the protected environment are managed by means of a &lt;tt&gt;longjmp&lt;/tt&gt;. If the code wrapped by &lt;tt&gt;lua_pcall&lt;/tt&gt; is a C++ function, it can instantiate objects. These objects have destructors. A &lt;tt&gt;longjmp&lt;/tt&gt; outside of the function means that no destructors will run... so objects will leak memory, file descriptors, and anything you can imagine. Doom's day.&lt;br /&gt;&lt;br /&gt;Yes, I know Lua can be rebuilt to report internal errors by means of exceptions which would make this particular problem a non-issue... but this rules out any pre-packaged Lua binaries (the default is to use &lt;tt&gt;longjmp&lt;/tt&gt; and henceforth what packaged binaries use). I do not want to embed Lua into my source tree.  I want to use Lua binary packages shipped with pretty much any OS (hey, including NetBSD!), which means that my code needs to be able to cope with Lua binaries that use &lt;tt&gt;setjmp&lt;/tt&gt;/&lt;tt&gt;longjmp&lt;/tt&gt; internally.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;&lt;b&gt;Closing remarks&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;I hope the above description makes any sense because I had to omit many, many details in order to make the post reasonably short. It could also be that there are other alternatives I have not considered, in which case I'd love to know them. Trying to find a solution to the above problem has already sucked several days of my free time, which translates in Kyua not seeing any further development until a solution is found!&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8550141972122584410?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8550141972122584410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8550141972122584410' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8550141972122584410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8550141972122584410'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/01/error-handling-in-lua.html' title='Error handling in Lua'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7770121345322078812</id><published>2011-01-02T03:22:00.003-05:00</published><updated>2011-01-02T04:26:32.257-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Understanding setjmp/longjmp</title><content type='html'>For a long time, I have been aware of the existence of the standard C functions &lt;tt&gt;setjmp&lt;/tt&gt; and &lt;tt&gt;longjmp&lt;/tt&gt; and that they can be used to simulate exceptions in C code. However, it wasn't until yesterday that I had to use them... and it was not trivial. The documentation for these functions tends to be confusing, and understanding them required looking for additional documents and a bit of experimentation. Let's see if this post helps in clarifying how these functions work.&lt;br /&gt;&lt;br /&gt;The first call to &lt;tt&gt;setjmp&lt;/tt&gt; causes the process state (stack, CPU registers, etc.) to be saved in the provided &lt;tt&gt;jmp_buf&lt;/tt&gt; structure and, &lt;i&gt;then&lt;/i&gt;, a value of 0 to be returned. A subsequent call to &lt;tt&gt;longjmp&lt;/tt&gt; with the same &lt;tt&gt;jmp_buf&lt;/tt&gt; structure causes the process to go "back in time" to the state stored in said structure. The way this is useful is that, when going back in time, we tweak the return value of the &lt;tt&gt;setjmp&lt;/tt&gt; call so we can actually run a second (or third or more) path as if nothing had happened.&lt;br /&gt;&lt;br /&gt;Let's see an example:&lt;pre&gt;#include &amp;lt;setjmp.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;&lt;br /&gt;static jmp_buf buf;&lt;br /&gt;&lt;br /&gt;static void&lt;br /&gt;myfunc(void)&lt;br /&gt;{&lt;br /&gt;   printf("In the function.\n");&lt;br /&gt;&lt;br /&gt;   ... do some complex stuff ...&lt;br /&gt;&lt;br /&gt;   /* Go back in time: restore the execution context of setjmp&lt;br /&gt;    * but make the call return 1 instead of 0. */&lt;br /&gt;   longjmp(buf, 1);&lt;br /&gt;&lt;br /&gt;   printf("Not reached.\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main(void) {&lt;br /&gt;   if (setjmp(buf) == 0) {&lt;br /&gt;       /* Try block. */&lt;br /&gt;       printf("Trying some function that may throw.\n");&lt;br /&gt;       myfunc();&lt;br /&gt;       printf("Not reached.\n");&lt;br /&gt;   } else {&lt;br /&gt;       /* Catch block. */&lt;br /&gt;       printf("Exception caught.\n");&lt;br /&gt;   }&lt;br /&gt;   return EXIT_SUCCESS;&lt;br /&gt;}&lt;/pre&gt;The example above shows the following when executed:&lt;pre&gt;Trying some function that may throw.&lt;br /&gt;In the function.&lt;br /&gt;Exception caught.&lt;/pre&gt;So, what happened above? The code starts by calling &lt;tt&gt;setjmp&lt;/tt&gt; to record the execution state and the call returns 0, which causes the first part of the conditional to run. You can think of this clause as the "try" part of an exception-based code. At some point during the execution of &lt;tt&gt;myfunc&lt;/tt&gt;, an error is detected and is "thrown" by a call to &lt;tt&gt;longjmp&lt;/tt&gt; and a value of 1. This causes the process to go back to the execution of &lt;tt&gt;setjmp&lt;/tt&gt; but this time the call returns 1, which causes the second part of the conditional to run. You can think of this second clause as the "catch" part of an exception-based code.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is still unclear to me what the "execution context" stored in &lt;tt&gt;jmp_buf&lt;/tt&gt; is: the documentation does not explain what kind of resources are correctly unwinded when the call to &lt;tt&gt;longjmp&lt;/tt&gt; is made... which makes me wary of using this technique for exception-like handling purposes. Oh, and this is even less clear in the context of C++ code and, e.g. calls to destructors. Would be nice to expand the description of these APIs in the manual pages.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7770121345322078812?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7770121345322078812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7770121345322078812' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7770121345322078812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7770121345322078812'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/01/understanding-setjmplongjmp.html' title='Understanding setjmp/longjmp'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-872973582929028616</id><published>2011-01-01T14:37:00.003-05:00</published><updated>2011-01-01T14:45:45.349-05:00</updated><title type='text'>Happy new year!</title><content type='html'>Dear readers,&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;2011 is here so...&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;Happy new year!&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;I hope you all are having a nice holiday season and enjoyed the new year's eve celebration, should it be something special for you.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;My tentative resolutions for this year related to non-work and non-personal areas would be:&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;First, to revive this blog. I have been lately posting more frequently than has been usual and it has been a pleasant task. I would like to recover the habit of blogging several times per week and, for that, I need topics! Keep'em coming! I already have some topics on the queue but they need a bit of research on my side first.&lt;/li&gt;&lt;li&gt;Second, to bring &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt; to reality (i.e. to deprecate &lt;a href="http://www.NetBSD.org/~jmmv/atf/"&gt;ATF&lt;/a&gt;). Work is continuing intensively and a preliminary release should be ready during Q1. This release will bring the much-needed replacement for &lt;tt&gt;atf-run&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;And third... well, haven't thought that much about resolutions ;-) We will see.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-872973582929028616?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/872973582929028616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=872973582929028616' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/872973582929028616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/872973582929028616'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2011/01/happy-new-year.html' title='Happy new year!'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2369561165071062485</id><published>2010-12-27T04:06:00.007-05:00</published><updated>2010-12-27T11:08:06.327-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Using RAII to clean up temporary values from a stack</title><content type='html'>For the last couple of days, I have been playing around with the &lt;a href="http://www.lua.org/"&gt;Lua&lt;/a&gt; C API and have been writing a thin wrapper library for C++. The main purpose of this auxiliary library is to ensure that global interpreter resources such as the global state or the execution stack are kept consistent in the presence of exceptions &amp;mdash; and, in particular, that none of these are leaked due to programming mistakes when handling error codes.&lt;br /&gt;&lt;br /&gt;To illustrate this point, let's forget about Lua and consider a simpler case. Suppose we lost the ability to pass arguments and return values from functions in C++ and all we have is a stack that we pass around. With this in mind, we could implement a &lt;tt&gt;multiply&lt;/tt&gt; function as follows:&lt;pre&gt;void multiply(std::stack&lt; int &gt;&amp; context) {&lt;br /&gt;    const int arg1 = context.top();&lt;br /&gt;    context.pop();&lt;br /&gt;    const int arg2 = context.top();&lt;br /&gt;    context.pop();&lt;br /&gt;    context.push(arg1 * arg2);&lt;br /&gt;}&lt;/pre&gt;And we could call our function as this:&lt;pre&gt;std::stack&lt; int &gt; context;&lt;br /&gt;context.push(5);&lt;br /&gt;context.push(6);&lt;br /&gt;multiply(context);&lt;br /&gt;const int result = s.top();&lt;br /&gt;s.pop();&lt;/pre&gt;In fact, my friends, this is more-or-less what your C/C++ compiler is internally doing when converting code to assembly language. The way the stack is organized to perform calls is known as the &lt;a href="http://en.wikipedia.org/wiki/Calling_conventions"&gt;calling conventions&lt;/a&gt; of an ABI (language/platform combination).&lt;br /&gt;&lt;br /&gt;Anyway, back to our point. One important property of such a stack-based system is that any function that deals with the stack must leave it in a consistent state: if the function pushes temporary values (read: local variables) into the stack, such temporary values must be gone upon return no matter how the function terminates. Otherwise, the caller will not find the stack as it expects, which will surely cause trouble at a later stage. The above example works just fine because our function is extremely simple and does not put anything on the stack.&lt;br /&gt;&lt;br /&gt;But things get messier when our functions can fail halfway through, and, in particular, if such failures are signaled by exceptions. In these cases, the function will abort abruptly and the function must take care to clean up any values that may still be left on the stack. Let's consider another example:&lt;pre&gt;void magic(std::stack&lt; int &gt;&amp; context) {&lt;br /&gt;    const int arg1 = context.top();&lt;br /&gt;    context.pop();&lt;br /&gt;    const int arg2 = context.top();&lt;br /&gt;    context.pop();&lt;br /&gt;&lt;br /&gt;    context.push(arg1 * arg2);&lt;br /&gt;    context.push(arg1 / arg2);&lt;br /&gt;    try {&lt;br /&gt;        ... do something with the two values on top ...&lt;br /&gt;&lt;br /&gt;        context.push(arg1 - arg2);&lt;br /&gt;        try {&lt;br /&gt;            ... do something with the three values on top ...&lt;br /&gt;        } catch (...) {&lt;br /&gt;            context.pop();  // arg1 - arg2&lt;br /&gt;            throw;&lt;br /&gt;        }&lt;br /&gt;        context.pop();&lt;br /&gt;    } catch (...) {&lt;br /&gt;        context.pop();  // arg1 / arg2&lt;br /&gt;        context.pop();  // arg1 * arg2&lt;br /&gt;        throw;&lt;br /&gt;    }&lt;br /&gt;    context.pop();&lt;br /&gt;    context.pop();&lt;br /&gt;}&lt;/pre&gt;The above is a completely fictitious and useless function, but serves to illustrate the point.  &lt;tt&gt;magic()&lt;/tt&gt; starts by pushing two values on the stack and then performs some computation that reads these two values.  It later pushes an additional value and does some more computations on the three temporary values that are on the top of the stack.&lt;br /&gt;&lt;br /&gt;The "problem" is that the computation code can throw an exception. If it does, we must sanitize the stack to remove the two or three values we have already pushed. Otherwise, the caller will receive the exception, it will assume nothing has happened, and will leak values on the stack (bad thing). To prevent this, we have added a couple of try/catch clauses to capture these possible exceptions and to clean up the already-pushed values before exiting the function. Unfortunately, this gets old very quickly: having to add try/catch statements surrounding every call is boring, ugly, and hard to read (remember that, &lt;i&gt;potentially&lt;/i&gt;, any statement can throw an exception).  You can see this in the example above with the two nested try/catch blocks.&lt;br /&gt;&lt;br /&gt;To mitigate this situation, we can apply a &lt;a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization"&gt;RAII&lt;/a&gt;-like technique to make popping elements on errors completely transparent and automated. If we can make it transparent, writing the code is easier and reading it is trivial; if we can make it automated, we can be certain that our error paths (rarely tested!) correctly clean up any global state. In C++, destructors are &lt;i&gt;deterministically&lt;/i&gt; executed whenever a variable goes out of scope, so we can use this to our advantage to clean up temporary values. Let's consider this class:&lt;pre&gt;class temp_stack {&lt;br /&gt;    std::stack&lt; int &gt;&amp; _stack;&lt;br /&gt;    int _pop_count;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;    temp_stack(std::stack&lt; int &gt;&amp; stack_) :&lt;br /&gt;        _stack(stack_), _pop_count(0) {}&lt;br /&gt;&lt;br /&gt;    ~temp_stack(void)&lt;br /&gt;    {&lt;br /&gt;        while (_pop_count-- &gt; 0)&lt;br /&gt;            _stack.pop();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    void push(int i)&lt;br /&gt;    {&lt;br /&gt;        _stack.push(i);&lt;br /&gt;        _pop_count++;&lt;br /&gt;    }&lt;br /&gt;};&lt;/pre&gt;With this, we can rewrite our function as:&lt;pre&gt;void magic(std::stack&lt; int &gt;&amp; context) {&lt;br /&gt;    const int arg1 = context.top();&lt;br /&gt;    context.pop();&lt;br /&gt;    const int arg2 = context.top();&lt;br /&gt;    context.pop();&lt;br /&gt;&lt;br /&gt;    temp_stack temp(context);&lt;br /&gt;&lt;br /&gt;    temp_stack.push(arg1 * arg2);&lt;br /&gt;    temp_stack.push(arg1 / arg2);&lt;br /&gt;    ... do something with the two values on top ...&lt;br /&gt;&lt;br /&gt;    temp_stack.push(arg1 - arg2);&lt;br /&gt;    ... do something with the three values on top ...&lt;br /&gt;&lt;br /&gt;    // Yes, we can return now.  No need to do manual pop()s!&lt;br /&gt;}&lt;/pre&gt;Simple, huh?  Our &lt;tt&gt;temp_stack&lt;/tt&gt; function keeps track of how many elements have been pushed on the stack.  Whenever the function terminates, be it due to reaching the end of the body or due to an exception thrown anywhere, the &lt;tt&gt;temp_stack&lt;/tt&gt; destructor will remove all elements previously registered from the stack.  This ensures that the function leaves the global state (the stack) as it was on entry &amp;mdash; modulo the function parameters consumed as part of the calling conventions.&lt;br /&gt;&lt;br /&gt;So how does all this play together with Lua? Well, Lua maintains a stack to communicate parameters and return values between C and Lua. Such stack can be managed in a similar way with a RAII class, which makes it very easy to write native functions that deal with the stack and clean it up correctly in all cases.  I would like to show you some non-fictitious code right now, but it's not ready yet ;-)  But when it is, it will be part of &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt;.  Stay tuned!&lt;br /&gt;&lt;br /&gt;And, to conclude: to make C++ code robust, wrap objects that need manual clean up (pointers, file descriptors, etc.) with small wrapper classes that perform such clean up on destruction. These classes are typically fully inlined and contain a single member field, so they do not impose any performance penalty. But, on the contrary, your code can avoid the need of many try/catch blocks, which are tricky to get right and hard to validate.  (Unfortunately, this technique cannot be applied in, e.g. Java or Python, because the execution of the class destructors is completely non-deterministic and not guaranteed to happen whatsoever!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2369561165071062485?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2369561165071062485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2369561165071062485' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2369561165071062485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2369561165071062485'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/12/using-raii-to-clean-up-temporary-values.html' title='Using RAII to clean up temporary values from a stack'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-978193490637932340</id><published>2010-12-26T05:41:00.005-05:00</published><updated>2010-12-26T06:35:49.765-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><title type='text'>Dependency injection: simple class constructors</title><content type='html'>Following my &lt;a href="http://blog.julipedia.org/2010/12/dependency-injection-and-testing.html"&gt;previous post on dependency injection&lt;/a&gt; (DI for short), I wanted to show you today another example of code in which DI helps in making the code clearer and easier to validate. In this case, the person to blame for the original piece of code being criticized is me.&lt;br /&gt;&lt;br /&gt;The &lt;tt&gt;atffile&lt;/tt&gt; module in ATF provides a class to represent the contents of &lt;tt&gt;Atffile&lt;/tt&gt;s. An &lt;tt&gt;Atffile&lt;/tt&gt; is, basically, a file containing a list of test programs to run and a list of properties associated to these test programs. Let's consider the original implementation of this module:&lt;pre&gt;class atffile {&lt;br /&gt;    strings_vector _test_programs;&lt;br /&gt;    strings_vector _properties;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;    atffile(const path&amp; file)&lt;br /&gt;    {&lt;br /&gt;        std::ifstream input(file.c_str());&lt;br /&gt;        _test_programs = ... parse list from input ...;&lt;br /&gt;        _properties = ... parse list from input ...;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    ... getters and other read-only methods ...&lt;br /&gt;};&lt;/pre&gt;According to the object-oriented programming (OOP) principles we are taught over and over again, this seems like a reasonable design. An &lt;tt&gt;atffile&lt;/tt&gt; object is entirely self-contained: if the constructor finishes successfully, we know that the new object matches exactly the representation of an &lt;tt&gt;Atffile&lt;/tt&gt; on disk. The other methods in the class provide read-only access to the internal attributes, which ensures that the in-memory representation remains consistent.&lt;br /&gt;&lt;br /&gt;However, this design couples the initialization of an object with external dependencies, and that is bad for two main reasons: first, because it makes testing (very) difficult; and, second, because it makes an apparently simple action (constructing an object) a potentially expensive task (reading from an external resource).&lt;br /&gt;&lt;br /&gt;To illustrate the first point, let's consider a helper free-function that deals with an &lt;tt&gt;atffile&lt;/tt&gt; object:&lt;pre&gt;std::string&lt;br /&gt;get_property(const atffile&amp; file, const std::string&amp; name,&lt;br /&gt;             const std::string&amp; defvalue)&lt;br /&gt;{&lt;br /&gt;    const strings_vector&amp; props = file.properties();&lt;br /&gt;    const strings_vector::const_iterator iter =&lt;br /&gt;        props.find(name);&lt;br /&gt;    if (iter == props.end())&lt;br /&gt;        return defvalue;&lt;br /&gt;    else&lt;br /&gt;        return *iter;&lt;br /&gt;}&lt;/pre&gt;Now, how do we write unit-tests for this function? Note that, to execute this function, we need to pass in an &lt;tt&gt;atffile&lt;/tt&gt; object. And to instantiate an &lt;tt&gt;atffile&lt;/tt&gt;, we need to be able to read a &lt;tt&gt;Atffile&lt;/tt&gt; from disk because the only constructor for the &lt;tt&gt;atffile&lt;/tt&gt; class has this dependency on an external subsystem. So, summarizing, to test this innocent function, we need to create a file on disk with valid contents, we need to instantiate an &lt;tt&gt;atffile&lt;/tt&gt; object pointing to this file, and only then we can pass it to the &lt;tt&gt;get_property&lt;/tt&gt; function. At this point, our unit test smells like an integration test, and it actually is for no real reason. This will cause our test suite to be more fragile (the test for this auxiliary function depends on the parsing of a file) and &lt;i&gt;slow&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;How can we improve the situation? Easy: decoupling the dependencies on external systems from the object initialization. Take a look at this rewritten &lt;tt&gt;atffile&lt;/tt&gt; class:&lt;pre&gt;class atffile {&lt;br /&gt;    strings_vector _test_programs;&lt;br /&gt;    strings_vector _properties;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;    atffile(const strings_vector&amp; test_programs_,&lt;br /&gt;            const strings_vector&amp; properties_) :&lt;br /&gt;        _test_programs(test_programs_),&lt;br /&gt;        _properties(properties_)&lt;br /&gt;    {&lt;br /&gt;        assert(!_test_programs.empty());&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    static atffile&lt;br /&gt;    parse(const path&amp; file)&lt;br /&gt;    {&lt;br /&gt;        std::ifstream input(file.c_str());&lt;br /&gt;        strings_vector test_programs_ =&lt;br /&gt;            ... parse list from input ...;&lt;br /&gt;        strings_vector properties_ =&lt;br /&gt;            ... parse list from input ...;&lt;br /&gt;        return atffile(test_programs_, properties_);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    ... getters and other read-only methods ...&lt;br /&gt;};&lt;/pre&gt;Note that this new design does &lt;i&gt;not&lt;/i&gt; necessarily violate OOP principles: yes, we can now construct an object with fake values in it by passing them to the constructor, but that does not mean that such values can be inconsistent once the object is created. In this particular example, I have added an assertion in the constructor to reenforce a check performed by &lt;tt&gt;parse&lt;/tt&gt; (that an &lt;tt&gt;atffile&lt;/tt&gt; must list at least one test program).&lt;br /&gt;&lt;br /&gt;With this new design in mind, it is now trivial to test the &lt;tt&gt;get_property&lt;/tt&gt; function shown above: constructing an auxiliary &lt;tt&gt;atffile&lt;/tt&gt; object is easy, because we can &lt;i&gt;inject&lt;/i&gt; values into the object to later pass it to &lt;tt&gt;get_property&lt;/tt&gt;: no need to create a temporary file that has to be valid and later parsed by the &lt;tt&gt;atffile&lt;/tt&gt; code. Our test now follows the true sense of a &lt;i&gt;unit&lt;/i&gt; test, which is much faster, less fragile and "to-the-point". We can later write integration tests if we so desire. Additionally, we can also write tests for &lt;tt&gt;atffile&lt;/tt&gt; member functions, and we can very easily reproduce corner cases for them by, for example, injecting bad data. The only place where we need to create temporary &lt;tt&gt;Atffile&lt;/tt&gt;s is when we need to test the &lt;tt&gt;parse&lt;/tt&gt; class method.&lt;br /&gt;&lt;br /&gt;So, to conclude: &lt;b&gt;make your class constructors as simple as possible&lt;/b&gt; and, in particular, &lt;b&gt;do not make your class constructors depend on external systems&lt;/b&gt;. If you find yourself opening resources or constructing other objects from within your constructor, you are doing it wrong (with very few exceptions).&lt;br /&gt;&lt;br /&gt;I have been using the above principle for the last ~2 years and the results are neat: I am much, much more confident on my code because I write lots of more accurate test cases and I can focalize dependencies on external resources on a small subset of functions. (Yes, &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt; uses this design pattern intensively!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-978193490637932340?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/978193490637932340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=978193490637932340' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/978193490637932340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/978193490637932340'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/12/dependency-injection-simple-class.html' title='Dependency injection: simple class constructors'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5704770792078981487</id><published>2010-12-23T11:11:00.004-05:00</published><updated>2010-12-23T12:13:07.058-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><title type='text'>Dependency injection and testing: an example</title><content type='html'>A coworker just sent me some Python code for review and, among such code, there was the addition of a function similar to:&lt;pre&gt;def PathWithCurrentDate(prefix, now=None):&lt;br /&gt;    """Extend a path with a year/month/day subdirectory layout.&lt;br /&gt;&lt;br /&gt;    Args:&lt;br /&gt;        prefix: string, The path to extend with the date subcomponents.&lt;br /&gt;        now: datetime.date, The date to use for the path; if None, use&lt;br /&gt;            the current date.&lt;br /&gt;&lt;br /&gt;    Returns:&lt;br /&gt;        string, The new computed path with the date appended.&lt;br /&gt;    """&lt;br /&gt;    path = os.path.join(prefix, '%Y', '%m', '%d')&lt;br /&gt;    if now:&lt;br /&gt;        return now.strftime(path)&lt;br /&gt;    else:&lt;br /&gt;        return datetime.datetime.now().strftime(path)&lt;/pre&gt;The purpose of this function, as the docstring says, is to simplify the construction of a path that lays out files on disk depending on a given date.&lt;br /&gt;&lt;br /&gt;This function works just fine... but it has a serious design problem (in my opinion) that you only see when you try to write unit tests for such function (guess what, the code to review did not include any unit tests for this). If I ask you to write tests for &lt;tt&gt;PathWithCurrentDate&lt;/tt&gt;, how would you do that? You would need to consider these cases (at the very very least):&lt;div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Passing &lt;tt&gt;now=None&lt;/tt&gt; correctly fetches the current date. To write such a test, we must stub out the call to &lt;tt&gt;datetime.datetime.now()&lt;/tt&gt; so that our test is deterministic. This is easy to do with helper libraries but does not count as trivial to me.&lt;/li&gt;&lt;li&gt;Could &lt;tt&gt;datetime.datetime.now()&lt;/tt&gt; raise an exception? If so, test that the exception is correctly propagated to match the function contract.&lt;/li&gt;&lt;li&gt;Passing an actual date to &lt;tt&gt;now&lt;/tt&gt; works. We know this is a different code path that does not call &lt;tt&gt;datetime.datetime.now()&lt;/tt&gt;, but still we must stub it out to ensure that the test is not going through that past in case the current date actually matches the date hardcoded in the test as an argument to &lt;tt&gt;now&lt;/tt&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;My point is: why is such a trivial function so complex to validate? Why such a trivial function needs to depend on external state? Things become more obvious if we take a look at a caller of this function:&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre&gt;def BackupTree(source, destination):&lt;br /&gt;    path = PathWithCurrentDate(destination)&lt;br /&gt;    CreateArchive(source, os.path.join(path, 'archive.tar.gz'))&lt;/pre&gt;Now, question again: how do we test this? Our tests would look like:&lt;pre&gt;def testOk(self):&lt;br /&gt;    # Why do we even have to do this?&lt;br /&gt;    ... create stub for datetime.datetime.now() to return a fake date ...&lt;br /&gt;&lt;br /&gt;   CreateArchive('/foo', '/backups/prefix')&lt;br /&gt;   ... validate that the archive was generated in the fake date directory ...&lt;/pre&gt;Having to stub out the call to &lt;tt&gt;datetime.datetime.now()&lt;/tt&gt; before calling &lt;tt&gt;CreateArchive&lt;/tt&gt; is a really, really weird thing at first glance. To be able to write this test, you must have deep insight of how the auxiliary functions called within the function work to know what dependencies on external state they have. Lots of black magic involved.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;All this said, the above may not seem like a big issue because, well, a call to &lt;tt&gt;datetime.datetime.now()&lt;/tt&gt; is cheap. But imagine that the call being performed deep inside the dependency tree was more expensive and dealt with some external state that is hard to mock out.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The trick to make this simpler and clearer is to apply a form of &lt;a href="http://en.wikipedia.org/wiki/Dependency_injection"&gt;Dependency injection&lt;/a&gt; (or, rather, "value injection"). We want the &lt;tt&gt;PathWithCurrentDate&lt;/tt&gt; function to be a simple data manipulation routine that has no dependencies on external state (i.e. make it purely functional). The easiest way to do so is to remove the &lt;tt&gt;now=None&lt;/tt&gt; code path and pass the date in right from the most external caller (aka, the &lt;tt&gt;main()&lt;/tt&gt; program).  For example (skipping docstrings for brevity):&lt;/div&gt;&lt;pre&gt;def PathWithCurrentDate(prefix, now):&lt;br /&gt;    path = os.path.join(prefix, '%Y', '%m', '%d')&lt;br /&gt;    return now.strftime(path)&lt;br /&gt;&lt;br /&gt;def BackupTree(source, destination, backup_date):&lt;br /&gt;    path = PathWithCurrentDate(destination, backup_date)&lt;br /&gt;    CreateArchive(source, os.path.join(path, 'archive.tar.gz'))&lt;/pre&gt;With this approach, the dependency on &lt;tt&gt;datetime.datetime.now()&lt;/tt&gt; (aka, a dependency on global state) completely vanishes from the code. The code paths to validate are less, and they are much simpler to test. There is no need to stub out a function call seemingly unused by &lt;tt&gt;BackupTree&lt;/tt&gt;.&lt;br /&gt;&lt;br /&gt;Another advantage of this approach can be seen if we were to have multiple functions accessing the same path. In this case, we would need to ensure that all calls receive the exact same date... what if the program kept running past 12AM and the "now" value changed? It is trivial to reason about this feature if the code does not have hidden queries to "now" (aka global state) within the code... but it becomes tricky to ensure our code is right if we can't easily audit where the "now" value is queried from!&lt;br /&gt;&lt;br /&gt;The "drawback", as some will think, is that the caller of any of these functions must do more work on its own to provide the correct arguments to the called functions.  "And if I always want the backup to be created on the current directory, why can't the backup function decide on itself?", they may argue.  But, to me, the former is definitely not a drawback and the latter... is troublesome as explained in this post.&lt;br /&gt;&lt;br /&gt;Another "drawback", as some others would say, is that testing is not a goal. Indeed it is not: testing is only a means to "correct" code, but it is also true that having testable code often improves (internal) APIs and overall design.&lt;br /&gt;&lt;br /&gt;To conclude: the above is an over-simplistic case study and my explanations will surely not convince anyone to stop doing black evil "clever" magic from within functions (and, worse, from within constructors).  You will only realize that the above makes any sense when you start unit-testing your code. Start today! :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5704770792078981487?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5704770792078981487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5704770792078981487' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5704770792078981487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5704770792078981487'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/12/dependency-injection-and-testing.html' title='Dependency injection and testing: an example'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8011489772000862337</id><published>2010-12-22T09:48:00.004-05:00</published><updated>2010-12-22T09:53:32.680-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='lua'/><title type='text'>Kyua: Design of the configuration system</title><content type='html'>Over a week ago, I mostly finished the implementation of the runtime engine for test cases of &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt; and, along the way, realized that it is imperative to write a configuration system right now before the configuration code becomes messier than it already is.&lt;br /&gt;&lt;br /&gt;To that end, I spent the last week working on a &lt;a href="http://code.google.com/p/kyua/wiki/ConfigurationDesign"&gt;design document for the configuration system&lt;/a&gt;. Summarizing, the document describes what the requirements for the configuration files of Kyua are, what the possible alternatives to implement them are, and advocates the use of &lt;a href="http://www.lua.org/"&gt;Lua&lt;/a&gt; &amp;mdash; a tiny embedded programming language &amp;mdash; to bring these configuration files to life.&lt;br /&gt;&lt;br /&gt;It is your chance to get involved in the early stages of the development of Kyua! :-) Take a look at the &lt;a href="http://groups.google.com/group/kyua-discuss/browse_thread/thread/913edd8cf58567da"&gt;email to kyua-discuss asking for comments&lt;/a&gt; and feel free to join the mailing list ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8011489772000862337?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8011489772000862337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8011489772000862337' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8011489772000862337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8011489772000862337'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/12/kyua-design-of-configuration-system.html' title='Kyua: Design of the configuration system'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4900891917283867475</id><published>2010-12-21T03:50:00.004-05:00</published><updated>2010-12-21T04:12:20.711-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>Sticky bit trivia</title><content type='html'>Did you ever wonder where the "sticky" part of the "sticky bit" name comes from? I actually didn't, but I just came across the &lt;a href="http://en.wikipedia.org/wiki/Sticky_bit"&gt;Sticky bit page&lt;/a&gt; on Wikipedia through &lt;a href="http://twitter.com/#!/aarontoponce/status/17003438298636288"&gt;a tweet&lt;/a&gt; from &lt;a href="http://twitter.com/#!/AaronToponce"&gt;@AaronToponce&lt;/a&gt; and discovered why.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you have used any "recent" (the quotes are important) Unix-like system, you probably know what the sticky bit is used for: to restrict the deletion of files in a directory to, basically, the owner of such files. The sticky bit is used on &lt;tt&gt;/tmp&lt;/tt&gt; (among other directories) so that anyone can create temporary files in it but only those that created the temporary files can delete them.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But that's not all that is to know.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The original purpose of the sticky bit was to &lt;i&gt;mark frequently-used executable files so that the operating system kept their text segment on swap space&lt;/i&gt;. This speeded up subsequent executions of such programs because the system would not need to access the file system to load the binary: it could just use the image already kept in the swap space. This behavior became obsolete with the advent of memory-mapped executables.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now it's clear why the sticky bit has the name it has, isn't it?  But still, that's not all that is to know.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SunOS 4 introduced a new behavior for the sticky bit on regular, non-executable files: reads and writes to such files would bypass the buffer cache, thus basically telling the system to perform raw I/O on those files. This was particularly useful on swap files when NFS was involved.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;With the above, I have just tried to summarize you the information that is in NetBSD's &lt;a href="http://netbsd.gw.com/cgi-bin/man-cgi?chmod+2+NetBSD-current"&gt;chmod(2)&lt;/a&gt; and &lt;a href="http://netbsd.gw.com/cgi-bin/man-cgi?sticky+7+NetBSD-current"&gt;sticky(7)&lt;/a&gt; manual pages; they contain much more detailed information. (And yep, that's right: contrary to what the Wikipedia article says, NetBSD does &lt;b&gt;not&lt;/b&gt; support this behavior any more.) Hope you found this insightful if you did not know this little piece of history!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4900891917283867475?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4900891917283867475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4900891917283867475' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4900891917283867475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4900891917283867475'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/12/sticky-bit-trivia.html' title='Sticky bit trivia'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2846086964222969606</id><published>2010-12-17T10:43:00.003-05:00</published><updated>2010-12-17T11:00:51.980-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='twitter'/><title type='text'>Getting the hang of Twitter searches</title><content type='html'>I have had a &lt;a href="http://www.twitter.com/"&gt;Twitter&lt;/a&gt; account (&lt;a href="http://twitter.com/jmmv"&gt;@jmmv&lt;/a&gt;) for several years already but I have never leveraged its power.  Why? Well... basically because I have never known how.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://www.amazon.com/Twitterville-Businesses-Thrive-Global-Neighborhoods/dp/1591842794"&gt;Twitterville&lt;/a&gt; book by Shel Israel (&lt;a href="http://twitter.com/shelisrael"&gt;@shelisrael&lt;/a&gt;), which I have been reading lately, has opened my mind quite a bit. Twitter is not so much about posting status updates, but more about sharing content and starting/joining conversations with other people. Today I like to think of Twitter as a world-wide chat-room.&lt;br /&gt;&lt;br /&gt;Twitterville mentions many times that the key in Twitter usage is to search for content.  But finding content among all the junk that floats in Twitter is hard.  I had seen that it is possible to actually do searches in the Twitter web page, but that is not really usable.  Yes, you can search &lt;i&gt;once&lt;/i&gt; for something you are interested in... but you know what, you can do the same in any search engine and get more relevant results.&lt;br /&gt;&lt;br /&gt;To me, what has made a difference is to switch to a client that does actually support live searches (&lt;a href="http://www.tweetdeck.com/"&gt;TweetDeck&lt;/a&gt; in my case).  With such a client, all you have to do is create a search for any given topic you may be remotely interested in and status updates will just pop up in your client as soon as someone posts about that particular topic.  Easy, huh? See, it's like joining your favorite &lt;tt&gt;#topic&lt;/tt&gt; chat-room.&lt;br /&gt;&lt;br /&gt;With this in mind, you can, for example, create a search such as "&lt;tt&gt;#netbsd OR #freebsd OR #openbsd&lt;/tt&gt;" to get real-time tweets about these BSD operating systems.  It is a fact that you will see loads of junk (disable popup notifications recommended), but you will catch some interesting content.  And the best of it, you can reply to that content.  This is particularly useful because you can (try to) fix misconceptions that people have before they spread out too much.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;That said, the value you see in Twitter and how you use it, is fully up to you. Different people will find different use cases, all of them interesting on their own.&lt;br /&gt;&lt;br /&gt;And to conclude, I have to confess that while the above may seem obvious to many, it is something that has escaped my mind until last week.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2846086964222969606?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2846086964222969606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2846086964222969606' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2846086964222969606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2846086964222969606'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/12/getting-hang-of-twitter-searches.html' title='Getting the hang of Twitter searches'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7281154677415457898</id><published>2010-12-16T14:11:00.005-05:00</published><updated>2010-12-16T15:53:03.575-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='kyua'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>Introducing Kyua</title><content type='html'>Wow.  I have just realized that I have not blogged at all about the project that has kept me busy for the past two months!  Not good, not good.  "What is this project?", I hear.  Well, this project is &lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;A bit of background first: the &lt;a href="http://www.NetBSD.org/~jmmv/atf/"&gt;Automated Testing Framework&lt;/a&gt;, or ATF for short, is a project that I &lt;a href="http://blog.julipedia.org/2007/04/soc-selected-again.html"&gt;started during the Summer of Code of 2007&lt;/a&gt;. The major goal of ATF was, and still is, to provide a testing framework for the &lt;a href="http://www.NetBSD.org/"&gt;NetBSD&lt;/a&gt; operating system. The ATF framework is composed of a set of libraries to aid in the implementation of test cases in C, C++ and shell, and a set of tools to ease the execution of such test cases (&lt;tt&gt;atf-run&lt;/tt&gt;) and to generate &lt;a href="http://www.gson.org/netbsd/bugs/build/build/2010.12.14.20.09.43/test.html"&gt;reports&lt;/a&gt; of the execution (&lt;tt&gt;atf-report&lt;/tt&gt;).&lt;br /&gt;&lt;br /&gt;At that point in time, I would say that the original design of ATF was nice.  It made test programs intelligent enough to execute their test cases in a sandboxed environment.  Such test programs could be executed on their own (without &lt;tt&gt;atf-run&lt;/tt&gt;) and they exposed the same behavior as when they were run within the runtime monitor, &lt;tt&gt;atf-run&lt;/tt&gt;.  On paper this was nice, but in practice it has become a hassle.  Additionally, some of these design decisions mean that particular features (in particular, parallel execution of tests) cannot be implemented at all.  At the end of 2009 and beginning of 2010, I did some &lt;a href="http://blog.julipedia.org/2010/03/introducing-atf-nofork-branch.html"&gt;major refactorings&lt;/a&gt; to the code to make the test programs dumber and to move much of the common logic into &lt;tt&gt;atf-run&lt;/tt&gt;, which helped a lot in fixing the major shortcomings encountered by the users... but the result is that, today, we have a huge mess.&lt;br /&gt;&lt;br /&gt;Additionally, while ATF is composed of different modules conceptually separate from each other, there is some hard implementation couplings among them that impose severe restrictions during development.  Tangentially, during the past 2 years of working at Google (and coding mainly in Python), I have been learning new neat programming techniques to make code more testable... and these are not followed at all by ATF.  In fact, while the test suite of ATF seems very extensive, it definitely is not: there are many corner cases that are not tested and for which implementing tests would be &lt;i&gt;very&lt;/i&gt; hard (which means that nasty bugs have easily sneaked in into releases).&lt;br /&gt;&lt;br /&gt;Lastly, a very important point that affects directly the success of the project.  Outsiders that want to contribute to ATF have a huge entry barrier: the source repository is managed by &lt;a href="http://www.monotone.ca/"&gt;Monotone&lt;/a&gt;, the bug tracker is provided by Gnats (a truly user-unfriendly system), and the mailing lists are offered by majordomo. None of these tools is "standard" by today's common practices, and some of them are tied to NetBSD's hosting which puts some outsiders off.&lt;br /&gt;&lt;br /&gt;For all the reasons above and as this year has been moving along, I have gotten fed up with the ATF code base.  (OK, things are not &lt;i&gt;that&lt;/i&gt; bad... but in my mind they do ;-)  And here is where Kyua comes into the game.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/kyua/"&gt;Kyua&lt;/a&gt; is a project to address all the shortcomings listed above.  First of all, the project uses off-the-shelf development tools that should make it much, much easier for external people to contribute.  Secondly, the project intends to be much more modular, providing a clear separation between the different components and providing code that is easily testable.  Lastly, Kyua intends to remain compatible with ATF so that there are no major disruptions for users.  You can (and should) think of Kyua as ATF 2.0, not as a vastly different framework.&lt;br /&gt;&lt;br /&gt;As of today, Kyua implements a runtime engine that is on par, feature-wise, to the one provided by &lt;tt&gt;atf-run&lt;/tt&gt;.  It is able to run test cases implemented with the ATF libraries and it is able to test itself.  It currently contains 355 test cases that run in less than 20 seconds.  (Compare that to the 536 test cases of ATF, which take over a minute to run, and Kyua is still really far from catching up with all the functionality of ATF.)  Next actions involve implementing reports generation and configuration files.&lt;br /&gt;&lt;br /&gt;Anyway.  For more details on the project, I recommend you to read the &lt;a href="http://mail-index.netbsd.org/atf-devel/2010/11/13/msg000206.html"&gt;original posting to atf-devel&lt;/a&gt; or the project's &lt;a href="http://code.google.com/p/kyua/"&gt;main page&lt;/a&gt; and &lt;a href="http://code.google.com/p/kyua/w/list"&gt;wiki&lt;/a&gt;.  And of course, you can also download the preliminary source code to take a look!&lt;br /&gt;&lt;br /&gt;Enjoy :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7281154677415457898?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7281154677415457898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7281154677415457898' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7281154677415457898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7281154677415457898'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/12/introducing-kyua.html' title='Introducing Kyua'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5350257932595349556</id><published>2010-09-03T12:14:00.003-04:00</published><updated>2010-09-05T11:15:02.255-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>Creating atf-based tests for NetBSD src</title><content type='html'>Thanks to Antti Kantee's efforts, atf is seeing increasing visibility in the NetBSD community during the past few months. But one of the major concerns that we keep hearing from our developers is "Where is the documentation?".  Certainly I have been doing a pretty bad job at that, and the current in-tree documents are a bit disorganized.&lt;br /&gt;&lt;br /&gt;To fix the short-term problem, I have written a &lt;a href="http://wiki.NetBSD.org/tutorials/atf/"&gt;little tutorial&lt;/a&gt; that covers pretty much every aspect that you need to know to write atf tests and, in particular, how to write such tests for the NetBSD source tree.  Please refer to the &lt;a href="http://blog.netbsd.org/tnf/entry/new_tutorial_creating_atf_based"&gt;official announcement&lt;/a&gt; for more details.&lt;br /&gt;&lt;br /&gt;Comments are, of course, welcome!  And if you can use this tutorial to write your first tests for NetBSD, let me know :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5350257932595349556?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5350257932595349556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5350257932595349556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5350257932595349556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5350257932595349556'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/09/creating-atf-based-tests-for-netbsd-src.html' title='Creating atf-based tests for NetBSD src'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4316464728404819592</id><published>2010-07-02T11:18:00.003-04:00</published><updated>2010-07-02T11:22:20.301-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>ATF 0.10 released</title><content type='html'>Ladies and gentlemen: I have just released ATF 0.10!  This release with such a magic number includes lots of new exciting features and provides a much simplified source tree.&lt;br /&gt;&lt;br /&gt;Dive into the &lt;a href="http://www.netbsd.org/~jmmv/atf/releases/0.10/"&gt;0.10 release page&lt;/a&gt; for details!&lt;br /&gt;&lt;br /&gt;I'm now working in getting this release into the NetBSD tree to remove some of the custom patches that have been superseded by the official release. Will be there soon.&lt;br /&gt;&lt;br /&gt;And all this while I am a &lt;a href="http://www.meetbsd.org/"&gt;meetBSD&lt;/a&gt; in Kraków :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4316464728404819592?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4316464728404819592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4316464728404819592' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4316464728404819592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4316464728404819592'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/07/atf-010-released.html' title='ATF 0.10 released'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1741546407166795638</id><published>2010-06-24T04:20:00.002-04:00</published><updated>2010-06-24T04:31:11.559-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>Testing NetBSD: Easy Does It</title><content type='html'>Antti Kantee has been, for a while, writing unit/integration tests for the puffs and rump systems (for which he is the author) shipped with NetBSD.  Recently, he has been working on fixing the NetBSD test suite to report 0 failures in the i386 platform so as to encourage developers to keep it that way while doing changes to the tree.  The goal is to require developers to run the tests themselves before submitting code.&lt;br /&gt;&lt;br /&gt;Antti has just published an introductory article, titled &lt;a href="http://blog.netbsd.org/tnf/entry/testing_netbsd_easy_does_it"&gt;Testing NetBSD: Easy Does It&lt;/a&gt;, that describes what &lt;a href="http://www.NetBSD.org/~jmmv/atf/"&gt;ATF&lt;/a&gt; and &lt;a href="http://www.gson.org/netbsd/anita/"&gt;Anita&lt;/a&gt; are, how to use them and how they can help in NetBSD development and deployment.  Nice work!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1741546407166795638?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1741546407166795638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1741546407166795638' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1741546407166795638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1741546407166795638'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/06/testing-netbsd-easy-does-it.html' title='Testing NetBSD: Easy Does It'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5879847356596187843</id><published>2010-06-18T13:48:00.003-04:00</published><updated>2010-06-18T13:51:20.223-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>ATF 0.9 released (late announcement)</title><content type='html'>Oops! Looks like I forgot to announce the &lt;a href="http://www.netbsd.org/~jmmv/atf/news.html#20100603-atf-0-9-released"&gt;release of ATF 0.9&lt;/a&gt; here a couple of weeks ago. Just a short notice that the formal release has been available since June 3rd and that 0.9 has been in NetBSD since June 4th!&lt;br /&gt;&lt;br /&gt;You can also enjoy a &lt;a href="http://www.netbsd.org/~jmmv/atf/"&gt;shiny-new web site&lt;/a&gt;! It even includes a &lt;a href="http://www.netbsd.org/~jmmv/atf/docs/faq.html"&gt;FAQ&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;And, as a side note: I have added a &lt;tt&gt;test&lt;/tt&gt; target to the NetBSD Makefiles, so now it's possible to just do &lt;tt&gt;make test&lt;/tt&gt; within any subdirectory of &lt;tt&gt;src/tests/&lt;/tt&gt; and get what you expect.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5879847356596187843?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5879847356596187843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5879847356596187843' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5879847356596187843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5879847356596187843'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/06/atf-09-released-late-announcement.html' title='ATF 0.9 released (late announcement)'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-7270221803608994472</id><published>2010-05-10T14:33:00.004-04:00</published><updated>2010-05-10T14:38:42.021-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>Trac installation for ATF</title><content type='html'>During the past few months, I've got into the habit of using a bug tracker to organize my tasks at the work place. People assign tickets to me to get things done and I also create and self-assign tickets to myself to keep them as a reminder of the mini-projects to be accomplished. Sincerely, this approach works very well for me and keeps me focused.&lt;br /&gt;&lt;br /&gt;Since then, I've been wishing to have a similar system set up for ATF.  Yeah, we could use the &lt;a href="http://www.netbsd.org/Gnats/"&gt;Gnats&lt;/a&gt; installation provided by NetBSD... but I hate this issue tracking system.  It's ancient, ugly, and I do really want a web interface to manage my tickets through.&lt;br /&gt;&lt;br /&gt;So, this weekend, I finally took some time and set up a Trac installation for ATF to provide a decent bug/task tracking system. The whole Apache plus Trac setup was more complex than I imagined, but I do hope that the results will pay off :-)&lt;br /&gt;&lt;br /&gt;Take a look at the &lt;a href="http://www.NetBSD.org/~jmmv/atf/news.html#20100509-trac-available"&gt;official announcement&lt;/a&gt; for more details!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-7270221803608994472?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/7270221803608994472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=7270221803608994472' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7270221803608994472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/7270221803608994472'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/05/trac-installation-for-atf.html' title='Trac installation for ATF'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-3049034875819271527</id><published>2010-05-10T05:22:00.003-04:00</published><updated>2010-05-10T05:28:32.946-04:00</updated><title type='text'>Ads gone</title><content type='html'>Almost a year ago, I decided to &lt;a href="http://blog.julipedia.org/2009/06/trying-adsense.html"&gt;give a try to AdSense&lt;/a&gt;. And, so far, the "earnings" have been ~30 EUR which I cannot even cash. Given this and how ugly and disturbing the ads look on the front page, I have disabled them. (I think the ads have gotten much worse over time... but as I do not pay attention to the front page, I didn't see them.) Thanks to Roman Valls for pointing this out!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-3049034875819271527?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/3049034875819271527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=3049034875819271527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3049034875819271527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/3049034875819271527'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/05/ads-gone.html' title='Ads gone'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5123310572457338623</id><published>2010-05-08T04:21:00.002-04:00</published><updated>2010-05-08T04:25:01.535-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>ATF 0.8 imported into NetBSD</title><content type='html'>Finished &lt;a href="http://mail-index.netbsd.org/source-changes/2010/05/08/msg009703.html"&gt;importing ATF 0.8 into the NetBSD source tree&lt;/a&gt;.  Wow, the CVS import plus merge was much easier than I expected.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Note that, while the NetBSD test suite should continue to work as usual, there are some backwards incompatible changes in the command line interface of test programs.  If you are used to run them by hand, expect different results.  Please read the &lt;a href="http://www.NetBSD.org/~jmmv/atf/news.html#20100507-atf-0-8-released"&gt;release news&lt;/a&gt; for details.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now let's wait for complaints about broken builds!  And enjoy this new release in your NetBSD-current system!&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5123310572457338623?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5123310572457338623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5123310572457338623' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5123310572457338623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5123310572457338623'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/05/atf-08-imported-into-netbsd.html' title='ATF 0.8 imported into NetBSD'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5230262632323813624</id><published>2010-05-07T10:41:00.003-04:00</published><updated>2010-05-07T11:33:47.627-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>Announcing ATF 0.8</title><content type='html'>Looks like today is a release day.  I've just pushed &lt;a href="http://www.NetBSD.org/%7Ejmmv/atf/news.html#20100507-atf-0-8-released"&gt;ATF 0.8&lt;/a&gt; out in the wild and will proceed to import it into pkgsrc and NetBSD later.  Refer to the release announcement for details.  This is an exciting release!  You have been warned ;-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5230262632323813624?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5230262632323813624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5230262632323813624' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5230262632323813624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5230262632323813624'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/05/announcing-atf-08.html' title='Announcing ATF 0.8'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6570217818735603714</id><published>2010-05-07T05:03:00.003-04:00</published><updated>2010-05-07T05:11:39.949-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='etcutils'/><category scheme='http://www.blogger.com/atom/ns#' term='pkgsrc'/><title type='text'>Announcing etcutils 0.1</title><content type='html'>During past week, I worked on a new package called etcutils. It provides a (reduced) tool-set to programmatically manage files in &lt;tt&gt;/etc&lt;/tt&gt; and is specially designed to allow pkgsrc to update &lt;tt&gt;/etc/shells&lt;/tt&gt; and &lt;tt&gt;/etc/services&lt;/tt&gt; in a more consistent way.&lt;br /&gt;&lt;br /&gt;I'm happy to say that the 0.1 release is now ready!  Go to the &lt;a href="http://www.netbsd.org/%7Ejmmv/etcutils/"&gt;etcutils web page&lt;/a&gt; for details.  (I know that if you are a Linux user, you probably don't care about this because your distribution most likely already provides something similar... albeit more complex.)&lt;br /&gt;&lt;br /&gt;I'll now proceed to import this new package into pkgsrc as &lt;tt&gt;sysutils/etcutils&lt;/tt&gt;.  Later on (most likely not today), the following should happen: rework pkginstall to use the new shells(8) utility to update &lt;tt&gt;/etc/shells&lt;/tt&gt;, add a new feature to pkgsrc to abstract the updates to &lt;tt&gt;/etc/services&lt;/tt&gt;, and swipe through pkgsrc to make all packages touching this file use the new frameworky option.  (Hey FAM, that includes you!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6570217818735603714?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6570217818735603714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=6570217818735603714' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6570217818735603714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6570217818735603714'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/05/announcing-etcutils-01.html' title='Announcing etcutils 0.1'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-6205418080955020541</id><published>2010-04-24T17:24:00.004-04:00</published><updated>2010-04-24T17:31:49.544-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='portability'/><title type='text'>Forget about test(1)'s == operator</title><content type='html'>Some implementations of test(1), in an attempt to be smart, provide non-standard operators such as &lt;tt&gt;==&lt;/tt&gt;. Please forget about those: they make your scripts non-portable and a pain to use in other systems. Why? Because, due to the way the shell works, failures in calls to test(1) will often just result in an error message (which may not be seen due to other output) and the script will happily continue running even if it missed to perform some important operation.&lt;br /&gt;&lt;br /&gt;So... just use the standard equality operators:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;tt&gt;=&lt;/tt&gt; for string equality comparison.&lt;/li&gt;&lt;li&gt;&lt;tt&gt;-eq&lt;/tt&gt; for numeric equality comparison.&lt;/li&gt;&lt;/ul&gt;Note that whenever I refer to test(1), I'm also talking about the &lt;tt&gt;[ ... ]&lt;/tt&gt; construction in conditionals.&lt;br /&gt;&lt;br /&gt;Also, please note that this also affects configure scripts, and the problem in these appears much more commonly than in other scripts!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-6205418080955020541?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/6205418080955020541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=6205418080955020541' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6205418080955020541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/6205418080955020541'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/04/forget-about-test1s-operator.html' title='Forget about test(1)&apos;s == operator'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1519509019468318358</id><published>2010-04-22T09:51:00.005-04:00</published><updated>2010-04-22T13:07:55.112-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='portability'/><title type='text'>Always define an else clause for portability #ifdefs</title><content type='html'>If you use &lt;tt&gt;#ifdef&lt;/tt&gt; conditionals in your code to check for portability features, be sure to always define a catch-all else clause that actually does something, even if this something is to error out.&lt;br /&gt;&lt;br /&gt;Consider the following code snippet, quoted from gamin's &lt;tt&gt;tests/testing.c&lt;/tt&gt; file:&lt;pre&gt;if (arg != NULL) {&lt;br /&gt;#ifdef HAVE_SETENV&lt;br /&gt;  setenv("GAM_CLIENT_ID", arg, 1);&lt;br /&gt;#elif HAVE_PUTENV&lt;br /&gt;  char *client_id = malloc (strlen (arg) + sizeof "GAM_CLIENT_ID=");&lt;br /&gt;  if (client_id)&lt;br /&gt;  {&lt;br /&gt;      strcpy (client_id, "GAM_CLIENT_ID=");&lt;br /&gt;      strcat (client_id, arg);&lt;br /&gt;      putenv (client_id);&lt;br /&gt;  }&lt;br /&gt;#endif /* HAVE_SETENV */&lt;br /&gt;}&lt;br /&gt;ret = FAMOpen(&amp;amp;(testState.fc));&lt;/pre&gt;The &lt;tt&gt;FAMOpen&lt;/tt&gt; method queries the &lt;tt&gt;GAM_CLIENT_ID&lt;/tt&gt; environment variable to set up the connections parameters to the FAM server. If the variable is not defined, the connection will still work, even though it will use some default internal value. In the test code above, the variable is explicitly set to let the tests use a separate server instance.&lt;br /&gt;&lt;br /&gt;Now, did you notice that we have to conditional branches? One for &lt;tt&gt;setenv&lt;/tt&gt; and one for &lt;tt&gt;putenv&lt;/tt&gt;? It seems reasonable to assume that one or the other must be present on any Unix system. Unfortunately, this is flawed:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;What happens if the code forgets to include &lt;tt&gt;config.h&lt;/tt&gt;?&lt;/li&gt;&lt;li&gt;What happens if the configure script fails to detect &lt;i&gt;both&lt;/i&gt; &lt;tt&gt;setenv&lt;/tt&gt; and &lt;tt&gt;putenv&lt;/tt&gt;? This is not that uncommon, given how some configure scripts are written.&lt;/li&gt;&lt;li&gt;What happens if neither &lt;tt&gt;setenv&lt;/tt&gt; nor &lt;tt&gt;putenv&lt;/tt&gt; are available?&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;The answer to the three questions is: in the above code snippet, the code &lt;tt&gt;builds just fine&lt;/tt&gt; but will misbehave at run time: neither &lt;tt&gt;HAVE_SETENV&lt;/tt&gt; nor &lt;tt&gt;HAVE_PUTENV&lt;/tt&gt; are defined, so the code will not be able to define the required environment variable. However, &lt;tt&gt;FAMOpen&lt;/tt&gt; will later be called and it will not behave as expected because the variable has not been set.&lt;br /&gt;&lt;br /&gt;Note that this code snippet is just an example. I have seen many more instances of this exact same problem with worse consequences than the above.  Read: they were not part of the test code, but just part of the regular code path.&lt;br /&gt;&lt;br /&gt;So how do you implement the above in a saner way? You have two alternatives:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Add an &lt;tt&gt;#else&lt;/tt&gt; clause that contains a fallback implementation. In the case above, we could, for example, prefer to use &lt;tt&gt;setenv&lt;/tt&gt; if present because it has a nicer interface, and fall back to &lt;tt&gt;putenv&lt;/tt&gt; if not found.&lt;br /&gt;This has a disadvantage though: if you forget to include &lt;tt&gt;config.h&lt;/tt&gt; or the configure script cannot correctly detect one of the possible implementations (even when present), you will always use the fallback implementation.&lt;/li&gt;&lt;li&gt;Keep each possible implementation correctly protected by a conditional, but add a &lt;tt&gt;#else&lt;/tt&gt; clause that raises an error at &lt;i&gt;build time&lt;/i&gt;. This will make sure that you never forget to define at least one of the portability macros for any reason. This is the preferred approach.&lt;/li&gt;&lt;/ul&gt;Following the second suggestion above, the code would get the following structure: &lt;pre&gt;#if defined(HAVE_SETENV)&lt;br /&gt;setenv(...);&lt;br /&gt;#elif defined(HAVE_PUTENV)&lt;br /&gt;putenv(...);&lt;br /&gt;#else&lt;br /&gt;#   error "Don't know how to set environment variables."&lt;br /&gt;#endif&lt;/pre&gt;With this code, we can be sure that the code will not build if none of the possible implementations are selected. We can later proceed to investigate why that happened.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1519509019468318358?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1519509019468318358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1519509019468318358' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1519509019468318358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1519509019468318358'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/04/always-define-else-clause-for.html' title='Always define an else clause for portability #ifdefs'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8725416766704267720</id><published>2010-04-21T04:08:00.003-04:00</published><updated>2010-04-21T04:27:53.873-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnome'/><title type='text'>Where does Gnome use file monitoring?</title><content type='html'>One of &lt;a href="http://blog.julipedia.org/2010/04/new-gio-fam-package.html?showComment=1271802660697#c3047587885904955995"&gt;my readers&lt;/a&gt; of my &lt;a href="http://blog.julipedia.org/2010/04/new-gio-fam-package.html"&gt;post yesterday&lt;/a&gt;, wonders where Gnome uses the file monitoring APIs. Well, the answer is: &lt;span style="font-style: italic;"&gt;everywhere&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Here are some examples:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Nautilus monitors all open folders so that it can update their contents whenever the underlying file store changes. Say you are viewing the Documents folder and you save a new Document from within OpenOffice into that folder. You definitely want Nautilus to show it immediately, without having to manually hit Refresh from the menu.&lt;/li&gt;&lt;li&gt;The trash applet monitors the trash folders and updates its icon from empty to full whenever one of these folders ceases to be non-empty.&lt;/li&gt;&lt;li&gt;The panel monitors the applications directory to notice when new applications get installed. This allows it to update the Applications menu immediately as soon as a new program gets installed into the system.&lt;/li&gt;&lt;li&gt;The GTK file open/save dialogs monitor the directory they are viewing for the same reason as Nautilus. (Actually, I'm unsure about this point. My Linux installation is an old Ubuntu 8.04 LTS that does not have GIO, so I can't verify in recent ones.  However, this makes perfect sense and if not implemented, it should be!)&lt;/li&gt;&lt;li&gt;The background switcher control panel monitors the folders containing images to be able to show new installed backgrounds. (I'm not sure about this either. It doesn't happen in my Linux installation, but it also makes sense.)&lt;/li&gt;&lt;li&gt;Media players such as Rhythmbox and Banshee allow you to point them to a folder containing music and have an option to automatically add music to the library as soon as it pops up in such folder.&lt;/li&gt;&lt;li&gt;Potentially, any document editor, picture viewer, etc. monitors the documents opened in them so that these applications can notice external notifications to those files. This is useful to prevent overwriting a file with an out-dated in-memory copy. For example: you are taking some notes with GEdit. On a separate terminal window, you quickly edit the notes file with Vim to add a new note. When you go back to GEdit, you want the editor to tell you that the file has changed out of its control and offer you a choice: e.g. reload or ignore?&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And many, many more other situations that I'm surely missing...&lt;br /&gt;&lt;br /&gt;As you can see, it is fairly important to get the file monitoring subsystem working flawlessly. Otherwise, all these tiny details don't work and the end user experience is undermined.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8725416766704267720?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8725416766704267720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8725416766704267720' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8725416766704267720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8725416766704267720'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/04/where-does-gnome-use-file-monitoring.html' title='Where does Gnome use file monitoring?'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4070965403269265546</id><published>2010-04-20T13:48:00.003-04:00</published><updated>2010-04-20T14:01:55.279-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pkgsrc'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>New gio-fam package</title><content type='html'>As briefly outlined in the &lt;a href="http://blog.julipedia.org/2010/04/file-system-monitoring-gnome-and-netbsd.html"&gt;previous post&lt;/a&gt;, new versions of Glib provide GIO, a library that intends to be a low-level file system API on top of the POSIX interface. This library provides an interface to asynchronously wait for file system change notifications including the creation, deletion and modification of files.&lt;br /&gt;&lt;br /&gt;The monitoring functionality in GIO is modular: it is backed by different loadable plugins that implement OS-specific functionality. In particular, GIO uses an inotify module in Linux and a &lt;a href="http://oss.sgi.com/projects/fam/"&gt;FAM&lt;/a&gt; module everywhere else.&lt;br /&gt;&lt;br /&gt;Up until now, the &lt;tt&gt;devel/glib2&lt;/tt&gt; package in pkgsrc provided a build-time option to specify whether to build the GIO FAM plugin or not. Given that this plugin is built as a shared object that is loaded dynamically at run-time, having a build-time option for this is clearly wrong: it gives no choice to those relying on binary packages (e.g. end/new users). Furthermore, it adds a dependency on the ugly-FAM at the very bottom of the huge Gnome dependency chain.  (As already stated, FAM is outdated and hard to set up.)&lt;br /&gt;&lt;br /&gt;So, based on this, I've just removed all FAM support from &lt;tt&gt;devel/glib2&lt;/tt&gt; altogether and packaged its loadable module as &lt;tt&gt;sysutils/gio-fam&lt;/tt&gt;.&lt;br /&gt;&lt;br /&gt;Now waiting for a clean rebuild of the Gnome packages to see if the desktop now works on my machine by avoiding FAM/Gamin.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4070965403269265546?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4070965403269265546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4070965403269265546' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4070965403269265546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4070965403269265546'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/04/new-gio-fam-package.html' title='New gio-fam package'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5347499839576127054</id><published>2010-04-20T09:21:00.006-04:00</published><updated>2010-04-20T12:12:38.206-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><category scheme='http://www.blogger.com/atom/ns#' term='gnome'/><title type='text'>File system monitoring, Gnome and NetBSD</title><content type='html'>A few days ago, I decided to start using NetBSD, as well as Gnome on NetBSD once again, mostly because the lack of their use makes my skills feel rusty in many different areas. While NetBSD has surprised me in a good way (I am running it on a Macbook Pro and things like wireless and DRI work), Gnome has not. There are tons of broken things that prevent a smooth user experience.&lt;br /&gt;&lt;br /&gt;One of these broken things is the monitoring of changes in the file system. Actually, this has never worked 100%. But what is this and why does it matter, you ask? Well, file system monitoring is an internal component of the Gnome infrastructure that allows the desktop to receive notifications when files or directories change. This way, if, say, you are viewing the Downloads folder in Nautilus and you start downloading a file from Epiphany into that folder, Nautilus will realize the new file and show it immediately without requiring a manual refresh.&lt;br /&gt;&lt;br /&gt;How to monitor the file system depends on the operating system. There are basically two approaches: polling and asynchronous notifications. Polling is suboptimal because the notifications are usually delayed. Asynchronous notifications are tied to the operating system: Linux provides &lt;a href="http://en.wikipedia.org/wiki/Inotify"&gt;inotify&lt;/a&gt;, NetBSD provides &lt;a href="http://en.wikipedia.org/wiki/Kqueue"&gt;kqueue&lt;/a&gt; and other systems provide their own APIs.&lt;span style="display: block;" id="formatbar_Buttons"&gt;&lt;span class="on down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;img src="http://www.blogger.com/img/blank.gif" alt="Link" class="gl_link" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;In the past, Gnome monitored the file system by a combination of &lt;a href="http://oss.sgi.com/projects/fam/"&gt;FAM&lt;/a&gt;, a system-level service that provides an API to file system monitoring, and GNOME VFS, a high-level layer that hides the interaction with FAM. This approach was good in spirit (client/server separation) but didn't work well:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;FAM is abandoned.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Does not support kqueue out of the box.&lt;/li&gt;&lt;li&gt;FAM runs as root.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;FAM is too hard to set up: it requires rpcbind, an addition to &lt;tt&gt;/etc/services&lt;/tt&gt;, a sysctl tweak, and the configuration of a system-level daemon.&lt;/li&gt;&lt;/ul&gt;To solve some of these problems, a drop-in replacement for FAM was started. &lt;a href="http://people.gnome.org/%7Eveillard/gamin/"&gt;Gamin&lt;/a&gt;, as it is known, still does not fix everything:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Gamin is abandoned.&lt;/li&gt;&lt;li&gt;Supports kqueue out of the box, but does not work very well.&lt;/li&gt;&lt;li&gt;Actually, Gamin itself does not work. Running the tests provided by the distfile in a modern Linux system results in several test failures.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Anyway. Did you notice the &lt;span style="font-style: italic;"&gt;abandoned&lt;/span&gt; pattern above?  This is important: in the new world order, Gnome does not use FAM any more.&lt;br /&gt;&lt;br /&gt;The new structure to monitor files is: the low-level glib library provides the gio module, which has some file system monitoring APIs. The GVFS module provides higher level abstractions to file system management, and relies on gio for file system monitoring. There is no more GNOME VFS any more.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-style: italic;"&gt;key&lt;/span&gt; point is: gio uses inotify directly; no abstraction layers in between. FAM support is still there for platforms without inotify, but as it is not used in Linux any more, it rots. Linux developers will never experience what it is to have a system that needs to use FAM to get this functionality to work.&lt;br /&gt;&lt;br /&gt;At last, let's look at the status of all this in NetBSD:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The FAM package was &lt;a href="http://blog.julipedia.org/2004/10/fam-and-kqueue.html"&gt;patched to support kqueue&lt;/a&gt;. Although this kinda works, it is not perfect. Also, as mentioned above, FAM is, I'd say, the package with the hardest installation procedure of the whole Gnome platform.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The Gamin packages are nicer than the FAM package regarding their configuration. However, when using Gamin instead of FAM, all sorts of bugs appear in Gnome (it actually gets stuck during startup for me). The breakage of the unit tests does not provide any confidence, and the fact that Gamin is abandoned, the idea of fixing it doesn't make me thrive.&lt;/li&gt;&lt;li&gt;The glib2 package &lt;span style="font-style: italic;"&gt;depends&lt;/span&gt; on FAM. This is ugly; really ugly. I had to shout WTF when I saw this, seriously.&lt;/li&gt;&lt;li&gt;Seeing the direction gio/gvfs take, it is obvious that things can only get worse in the future.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;If time permits, I'm planning to work on improving this whole situation. Ideas include:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Splitting the FAM gio module out of the glib2 package. Ideally, this would happen upstream.&lt;/li&gt;&lt;li&gt;Implement a gio backend for kqueue.&lt;/li&gt;&lt;li&gt;Check if the core packages still using gnome-vfs have a more recent version that uses gvfs instead and, if so, update them.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Can't promise you anything other than, if I get to work on it, I will keep you posted!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5347499839576127054?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5347499839576127054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5347499839576127054' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5347499839576127054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5347499839576127054'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/04/file-system-monitoring-gnome-and-netbsd.html' title='File system monitoring, Gnome and NetBSD'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1228455004173703548</id><published>2010-03-19T04:36:00.004-04:00</published><updated>2010-03-19T04:54:51.118-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='soc'/><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='pkgsrc'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>NetBSD in Google Summer of Code 2010</title><content type='html'>For the 6th year in a row, &lt;a href="http://www.netbsd.org/"&gt;NetBSD&lt;/a&gt; is a mentoring organization for &lt;a href="http://code.google.com/soc/"&gt;Google Summer of Code&lt;/a&gt; 2010!&lt;br /&gt;&lt;br /&gt;If you are a bright student willing to develop full-time for an open source project during this coming summer, consider applying with us! You will have a chance to work with very smart people and, most likely, in the area that you are most passionate about. NetBSD, being an operating system project, has offers for project ideas at all levels: from the kernel to the packaging system, passing by drivers, networking tools, user-space utilities, the system installer, automation tools and more!&lt;br /&gt;&lt;br /&gt;I would like to point you at the 3 project proposals I'm willing to directly mentor:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.netbsd.org/contrib/soc-projects.html#optimize-atf"&gt;Optimize and speed-up ATF&lt;/a&gt;: Make the testing framework blazing fast so that running the NetBSD automated tests does not take ages on slow platforms.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.netbsd.org/contrib/soc-projects.html#reorganize-atf"&gt;Reorganize ATF to improve modularity&lt;/a&gt;: Refactor pieces of the testing framework so that it is easier to redistribute, has cleaner interfaces and is easier to depend on from third-party projects.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.netbsd.org/contrib/soc-projects.html#rewrite-pkg_comp"&gt;Rewrite pkg_comp with portability as a major goal&lt;/a&gt;: Use Python to create a tool to automatically build binary packages from within a sandbox.&lt;/li&gt;&lt;/ul&gt;If you find any of the above projects interesting, or if you have any other project proposal that you think I could mentor, do not hesitate to &lt;a href="mailto:jmmv%20at%20netbsd%20dot%20org"&gt;contact me&lt;/a&gt;. Feel free to send me a draft of &lt;a href="http://www.netbsd.org/contrib/soc-application.html"&gt;your application&lt;/a&gt;, together with a bit of information about you, so that we can discuss your proposal and make sure it gets selected!&lt;br /&gt;&lt;br /&gt;Or, if none of the projects above interests you, please do check out the &lt;a href="http://www.netbsd.org/contrib/soc-projects.html"&gt;full list of NetBSD project proposals&lt;/a&gt;. I'm sure you will find something that suits your interests :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1228455004173703548?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1228455004173703548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1228455004173703548' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1228455004173703548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1228455004173703548'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/03/netbsd-in-google-summer-of-code-2010.html' title='NetBSD in Google Summer of Code 2010'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1599070089952057305</id><published>2010-03-12T04:30:00.002-05:00</published><updated>2010-03-12T04:41:34.588-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pkgsrc'/><category scheme='http://www.blogger.com/atom/ns#' term='monotone'/><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><title type='text'>New version of the monotone-server package in pkgsrc</title><content type='html'>Wow, it has been a long time... 5 years ago, I created the &lt;a href="http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/devel/monotone-server/?only_with_tag=MAIN"&gt;monotone-server&lt;/a&gt; package in pkgsrc, a package that provided an interactive script to set up a &lt;a href="http://monotone.ca/"&gt;monotone&lt;/a&gt; server from scratch with, what I though, minimal hassle.&lt;br /&gt;&lt;br /&gt;My package did the job just fine, but past year I was blown away by the simplicity of the same package in &lt;a href="http://www.fedoraproject.org/"&gt;Fedora&lt;/a&gt;: their &lt;tt&gt;init.d&lt;/tt&gt; script provides a set of extra commands to initialize the server before starting it up, and that is it. No need to mess with a separate interactive script; no need to create and memorize passphrases that you will never use; and, what's more, all integrated in the only single place that makes sense: in the init.d "service management" script.&lt;br /&gt;&lt;br /&gt;It has been a while since I became jealous of their approach, but I've finally got to it: I've spent the last few days rewriting the monotone-server package in pkgsrc and came up with a similar scheme.  And this &lt;a href="http://mail-index.netbsd.org/pkgsrc-changes/2010/03/12/msg038844.html"&gt;new package&lt;/a&gt; just made its way &lt;a href="http://mail-index.netbsd.org/pkgsrc-changes/2010/03/12/msg038844.html"&gt;&lt;/a&gt;to pkgsrc-HEAD!  The new package comes with what I think is a detailed manual page that explains how to configure the server from scratch.  Take a look and, if you find any mistakes, inconsistencies or improvements to be done, let me know!&lt;br /&gt;&lt;br /&gt;In the meantime, I will log into my home server, rebuild the updated package and put it in production :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1599070089952057305?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1599070089952057305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1599070089952057305' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1599070089952057305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1599070089952057305'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/03/new-version-of-monotone-server-package.html' title='New version of the monotone-server package in pkgsrc'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1501363386005733392</id><published>2010-03-06T15:00:00.003-05:00</published><updated>2010-03-06T15:06:36.296-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>Introducing the ATF nofork branch</title><content type='html'>Despite my time for free software being virtually zero these days, I have managed to implement a prototype of what ATF would look like if it didn't implement forking and isolation in test programs. This feature has been often requested by users to simplify their life when debugging test cases.&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I shouldn't repeat everything I posted on the atf-devel mailing list regarding this announcement, so please &lt;a href="http://mail-index.netbsd.org/atf-devel/2010/03/05/msg000070.html"&gt;refer to that email for details&lt;/a&gt;. But I must say that the results look promising: the overall code of ATF is much simpler and also faster. (An execution I just tried cuts the run time of the ATF test suite from 1m 41s to 1m 16s.)  Expect more simplifications and speed-ups!&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1501363386005733392?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1501363386005733392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1501363386005733392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1501363386005733392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1501363386005733392'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/03/introducing-atf-nofork-branch.html' title='Introducing the ATF nofork branch'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8947551254574129862</id><published>2010-01-24T16:52:00.003-05:00</published><updated>2010-01-24T16:58:10.315-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><title type='text'>set -e and set -x</title><content type='html'>If you write shell scripts, you definitely need to know about two nice features that can be enabled through the &lt;tt&gt;set&lt;/tt&gt; builtin:&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;tt&gt;set -e&lt;/tt&gt;: Enables checking of all commands. If a command exits with an error and the caller does not check such error, the script aborts immediately. Enabling this will make your scripts more robust. But don't wait until your script is "complete" to set the flag as an afterthought, because it will be a nightmare to fix the scrip to work with this feature enabled. Just write &lt;tt&gt;set -e&lt;/tt&gt; as the very first line of your code; well... after the shell bang.&lt;/li&gt;&lt;li&gt;&lt;tt&gt;set -x&lt;/tt&gt;: If you are writing simple scripts that are meant to, well, script the execution of a few tasks (as opposed of being full-flown programs written in shell), set this flag to trace the execution of all commands. This will make the interpreter print each command right before it is executed, so it will aid you in knowing what is happening at any point in time.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8947551254574129862?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8947551254574129862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8947551254574129862' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8947551254574129862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8947551254574129862'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/01/set-e-and-set-x.html' title='set -e and set -x'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1422463512138756573</id><published>2010-01-11T18:22:00.003-05:00</published><updated>2010-01-11T18:36:49.406-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='netbsd'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><title type='text'>Installing NetBSD/macppc on a Mac Mini G4</title><content type='html'>Yesterday, I spent a while installing NetBSD/macppc 5.0.1 on a Mac Mini G4.  The process wasn't easy, as it involved the following steps. I'm omitting many details, as they are "common knowledge" to Mac users (or otherwise can be easily found on the net):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;After booting the installer from the CD image, drop into the shell.&lt;/li&gt;&lt;li&gt;Use &lt;tt&gt;pdisk&lt;/tt&gt; to create an &lt;tt&gt;Apple_HFS&lt;/tt&gt; partition for the boot loader and two &lt;tt&gt;Apple_UNIX_SVR2&lt;/tt&gt; partitions, one for the root file system and another for swap.&lt;/li&gt;&lt;li&gt;Run &lt;tt&gt;sysinst&lt;/tt&gt; and install the system. When asked to repartition the disk, just say &lt;i&gt;Use existing partition sizes&lt;/i&gt;.&lt;/li&gt;&lt;li&gt;Once the system is installed, drop again into the shell before rebooting.&lt;/li&gt;&lt;li&gt;Mount your hard disk into &lt;tt&gt;/mnt&lt;/tt&gt; and chroot into it.&lt;/li&gt;&lt;li&gt;Fetch a copy of pkgsrc.&lt;/li&gt;&lt;li&gt;Install the &lt;tt&gt;sysutils/hfsutils&lt;/tt&gt; package.&lt;/li&gt;&lt;li&gt;Use &lt;tt&gt;hformat&lt;/tt&gt; to create a new HFS file system in the &lt;tt&gt;Apple_HFS&lt;/tt&gt; partition we created.&lt;/li&gt;&lt;li&gt;Mount the installation CD.&lt;/li&gt;&lt;li&gt;Copy, using &lt;tt&gt;hcopy&lt;/tt&gt;, the &lt;tt&gt;ofwboot.xcf&lt;/tt&gt; file from the CD to the boot partition.&lt;/li&gt;&lt;li&gt;Reboot.&lt;/li&gt;&lt;li&gt;Drop into the OpenFirmware setup (Command+Option+P+R).&lt;/li&gt;&lt;li&gt;Set &lt;tt&gt;boot-device&lt;/tt&gt; to &lt;tt&gt;hd:,\ofwboot.xcf&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;Set &lt;tt&gt;boot-file&lt;/tt&gt; to &lt;tt&gt;netbsd&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;And here is the tricky thing to get the machine to auto-boot: Set &lt;tt&gt;boot-command&lt;/tt&gt; to &lt;tt&gt;." hello" cr " screen" output boot&lt;/tt&gt;, not &lt;tt&gt;mac-boot&lt;/tt&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;I found the last command somewhere on the Internet (dunno where now), but, supposedly, a regular &lt;tt&gt;mac-boot&lt;/tt&gt; should have worked. In fact, it works if you call this command from the prompt, but not during automatic boot. (It turns out to be a problem with the version of OpenFirmware I have.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Just writing down the steps in case I need them later on. Installing Debian stable was much, much easier, but the installer for testing crashes every day with a different error, so I gave up.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;(Oh, by the way, I did the same installation into an old PowerMac G3 and that was really painful. The machine refused to boot from any of the CDs I tried and the prebuilt kernels hang during initialization due to a bogus driver. In the end: netbooting and using custom kernels.)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1422463512138756573?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1422463512138756573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1422463512138756573' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1422463512138756573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1422463512138756573'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2010/01/installing-netbsdmacppc-on-mac-mini-g4.html' title='Installing NetBSD/macppc on a Mac Mini G4'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-5706562320936440325</id><published>2009-10-25T08:33:00.002-04:00</published><updated>2009-10-25T08:43:08.845-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>Processing Makefile.am with M4</title><content type='html'>ATF's Makefile.am, which is a single Makefile for the whole tree, was already at the 1300 lines mark and growing. At this size, it is unmanageable, and a quick look at its contents reveals tons of repeated delicate code.&lt;br /&gt;&lt;br /&gt;Why so much repeated code, you ask, if the whole point of Automake is to simplify Makefiles? Automake does in fact simplify Makefile code when you define targets known by Automake, such as binaries and/or libraries. However, as soon as you start doing fancy things with documentation, building tons of small programs or messing with shell scripts, things get out of control because you are left on your own to define their targets and their necessary build logic.&lt;br /&gt;&lt;br /&gt;Up until now, I had just kept up with the boilerplate code... but now that I'm starting to add pretty complex rules to generate HTML and plain text documentation out of XML files, the complexity must go. And here comes my solution:&lt;br /&gt;&lt;br /&gt;I've just committed an experiment to &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/info/aca66742e00b236d0b6dcb22ae70468736b612bc"&gt;process Makefile.am with M4&lt;/a&gt;. I've been trying to look for prior art behind this idea and couldn't find any, so I'm not sure how well this will work. But, so far, this has cut down 350 lines of Makefile.am code.&lt;br /&gt;&lt;br /&gt;How does this work? First of all, I've written a script to generate the Makefile.am from the Makefile.am.m4 and put it in admin/generate-makefile.sh. All this script does is call M4, but I want to keep this logic in a single place because it has to be used from two call sites as described below.&lt;br /&gt;&lt;br /&gt;Then, I've added an autogen.sh script to the top-level directory that generates Makefile.am (using the previous script) and calls autoreconf -is. I'm against autogen.sh scripts that pretend to be smart instead of just calling autoreconf, but in this case I see no other way around it.&lt;br /&gt;&lt;br /&gt;At last, I've modified Makefile.am to add an extra rule to generate itself based on the M4 version. This, of course, also uses generate-makefile.sh.&lt;br /&gt;&lt;br /&gt;We'll see how this scales, but I'm so far happy with the results.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-5706562320936440325?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/5706562320936440325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=5706562320936440325' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5706562320936440325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/5706562320936440325'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/10/processing-makefileam-with-m4.html' title='Processing Makefile.am with M4'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-190748834219167977</id><published>2009-09-23T05:10:00.002-04:00</published><updated>2009-09-23T05:14:09.347-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pkgsrc'/><title type='text'>Extending sudo credentials</title><content type='html'>If you use sudo for, e.g. pkgsrc's just-in-time su, you may have often bitten by the problem that some compilations are slow and the build process stops right in the middle to ask you for a root password.  If you go away while the system compiles, you'll be frustrated when you come back, as the process may still well be at the very beginning.&lt;br /&gt;&lt;br /&gt;This happens because, unless disabled by the system administrator, your sudo credentials last for 5 minutes. If you hadn't used sudo for those 5 minutes, it will ask you for your password again. A simple workaround for the problem is to automatically renew your credentials, say, every 2 minutes. You can do this by running the following command (from the same console you are using later on!) right before starting a pkgsrc build:&lt;pre&gt;$ ( while :; do sudo -v; sleep 120; done ) &amp;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-190748834219167977?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/190748834219167977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=190748834219167977' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/190748834219167977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/190748834219167977'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/09/extending-sudo-credentials.html' title='Extending sudo credentials'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1338186479268297089</id><published>2009-08-31T07:36:00.004-04:00</published><updated>2009-08-31T07:39:33.178-04:00</updated><title type='text'>Best config setting ever</title><content type='html'>&lt;pre&gt;echo 'set editing-mode vi' &gt;&gt;~/.inputrc&lt;/pre&gt;This will enable vi-editing mode for all commands that use the GNU readline library (e.g. bash, python, bc, etc.), not only the shell.  For the shell only (including non-bash shells), add 'set -o vi' to your shrc file.&lt;br /&gt;&lt;br /&gt;I don't know why I didn't do this before given that I'm a pretty hard vi user.  Still, for some reason, I kept using emacs-like key bindings for command-line editing.  Not any more!  However, be careful: if you are used to vim's visual editing mode, you'll keep hitting 'v' in the command line and getting super annoyed.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1338186479268297089?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1338186479268297089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1338186479268297089' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1338186479268297089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1338186479268297089'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/08/best-config-setting-ever.html' title='Best config setting ever'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-681908603179050098</id><published>2009-08-03T15:59:00.002-04:00</published><updated>2009-08-03T16:02:32.120-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>1000 revisions for ATF</title><content type='html'>Mmm!  Revision &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/info/7ca234b9aceabcfe9a8a1340baa07d6fdc9e3d33"&gt;7ca234b9aceabcfe9a8a1340baa07d6fdc9e3d33&lt;/a&gt;, committed about an hour ago, marks the 1000th revision in the ATF repository.  Thanks for staying with me if you are following the project :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-681908603179050098?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/681908603179050098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=681908603179050098' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/681908603179050098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/681908603179050098'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/08/1000-revisions-for-atf.html' title='1000 revisions for ATF'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-9020484380911179497</id><published>2009-08-03T13:42:00.002-04:00</published><updated>2009-08-03T13:46:08.414-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='books'/><title type='text'>Books by Joel Spolsky</title><content type='html'>I just finished reading the third book in a row from Joel Spolsky, titled Joel on Software. Before this one, I read More Joel on Software and The Best Software Writing 1, all in a bit over a month. Note: I hadn't read any book cover-to-cover for a loooong while. Very interesting and entertaining books; highly recommended.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Oh, and his writing style is really enjoyable. We, crappy blog writers, can learn a lot from him!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-9020484380911179497?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/9020484380911179497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=9020484380911179497' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/9020484380911179497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/9020484380911179497'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/08/books-by-joel-spolsky.html' title='Books by Joel Spolsky'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-4743147252783979430</id><published>2009-07-27T17:19:00.004-04:00</published><updated>2009-07-29T07:53:59.446-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>Rearchitecting ATF</title><content type='html'>During the last few weeks, I've been doing some ATF coding and, well... I'm not happy. At all. I keep implementing features but I feel, more and more, that ATF is growing out of control and that it is way too sluggish. It oughtn't be so slow. About 6 minutes to run the whole test suite in a Mac G3 I just got? HA! I bet I can do much, much, much better than that. Come on, we are targeting NetBSD, so we should support all those niche platforms rather well, and speed matters.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The thing is, the current code base grew out of a prototype that didn't have that much of a design. Well, it had a design but, in my opinion, it has turned to be a bad design. I couldn't imagine that we could hit the bottlenecks (speed) and user-interface issues (for example, the huge difficulties that involve debugging a failing test case) that we are hitting.  So...&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;IT IS TIME FOR A CHANGE!!!&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I'm currently working on a written specification of what ATF will look like, hopefully, in the not-so-distant future. It will take a while to get there, but with enough effort, we soon will. And life will be better. And no, I'm not talking about a from-scratch rewrite; that'd only hurt the project. I plan to take incremental and safe steps, keeping the code base running all the time, but I will do a major face-lift of everything. (I wish I could say "we" instead of "I" here.  But not there yet.)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Why am I writing a specification, you ask? Well, because that forces me (or ANY developer) to think how I want the thing to look like and to decide, exactly, on what the design will be, which technologies will be used, which languages will be involved and in what components, etc. And no, I'm not talking of a class model design; I'm just talking about the main design of the whole picture, which is quite hard by itself. Plus having a spec will allow me to show it to you before I start coding and you will say "oh, wonderful, this new design sucks so much that I'm not going to bother with the new version". Or maybe hell will freeze and you will think, "mmm, this looks interesting, maybe it will solve these issues I'm having as regards speed, ease of debugging and ease of use".&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, I hope to have a draft "soon" and to hear any of the two possible comments as a result!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Edit (July 29th)&lt;/b&gt;: Alright, I have uploaded an &lt;a href="http://www.netbsd.org/~jmmv/rearchitecting-atf/spec.html"&gt;extremely preliminary copy of the specification&lt;/a&gt; just so that you can see where my current ideas are headed. Expect many more changes to this document, so don't pay too much attention to the tiny details (most of which aren't there anyway yet).&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-4743147252783979430?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/4743147252783979430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=4743147252783979430' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4743147252783979430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/4743147252783979430'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/07/rearchitecting-atf.html' title='Rearchitecting ATF'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-8981481737885658422</id><published>2009-07-13T20:37:00.003-04:00</published><updated>2009-07-13T21:03:22.432-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><title type='text'>The mess of ATF's code</title><content type='html'>Yes. ATF's code is a "bit" messy, to put it bluntly. I'm quite happy with some of the newest bits but there are some huge parts in it that stink. The main reason for this is that the "ugly" parts were the ones that were written first, and they were basically a prototype; we didn't know all the requirements for the code at that point... and we still don't know them, but we know we can do much better. Even though I'm writing in plural... I'm afraid we = I at the moment :-P&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, is it time for the big-rewrite-from-scratch? NO! Joel Spolsky wrote about why &lt;a href="http://www.joelonsoftware.com/articles/fog0000000348.html"&gt;this is a bad idea&lt;/a&gt; and I have to agree with him. Yeah, I'm basically the only developer of the code so everything is in my head, and I'd do a rewrite with a fresh mind, but... I'd lose tons of work and, specially, I'd lose tons of code that deals with tricky corner-cases that are hard to remember.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Sure, I want to clean things up but they'll happen incrementally. And preferably concurrently with feature additions. These two things could definitely happen at the same time if only I had infinite spare time...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Anyway, the major point of this post is to describe what I don't like about the current code base and how I'd like to see it changing:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;A completely revamped C++ API for test cases. The current one sucks. It is not consistent with the C API. It lacks important functionality. It uses exceptions for test-case status reporting (yuck!). And it's ugly.&lt;/li&gt;&lt;li&gt;Clear separation of "internal/helper" APIs from the test APIs. You'll agree that the "fs" module, which provides path abstraction and other file system management routines, is something that cannot be part of ATF's API. ATF is about testing. Period. Either that fs module should be in a separate library or should be completely hidden from the public. Otherwise, it'll suffer from abuse and, what scares me, will have to become part of ATF's API. And likewise, most &amp;mdash; really &amp;mdash; most of the modules in the current code are internal.&lt;/li&gt;&lt;li&gt;Less dependencies from the C++ API to the C API. Most of the current C++ modules are wrappers of their corresponding C counterparts. This is nice for code reuse but makes the code extremely fragile. In C++, things like RAII can provide really robust code with minimum effort, but intermixing such C++ code with C makes things ugly really quickly. I'd like to find a way to keep the two libraries separate from each other (and thus keep the C++ binding "pure"), but at the same time I don't want to duplicate code... an interesting problem.&lt;/li&gt;&lt;li&gt;Split the tarball into smaller pieces. People writing test cases for C applications don't want to pull in a huge package that depends on C++ and whatnot. And ATF is huge. It takes forever to compile. And this is a serious issue for broad adoption. Note: whether the tools are written in C++ or not is a separate issue, because these are not a dependency for anything!&lt;/li&gt;&lt;li&gt;The shell binding is slow. Really slow compared to the other ones. Optimizations would be nice, but those do not address the root of the problem: it's costly to query information from shell-based tests at run time. I.e. it takes a long time to get the full list of test cases available in a test suite because you have to run every single test program with the -l flag. Keeping a separate file with test-case metadata alongside the binary could resolve this and allow more flexibility at run time.&lt;/li&gt;&lt;li&gt;And some other things.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Those are the major things I'd like to see addressed soon, but they involve tons of work. Of course, I'd like to be able to work on some features expected by other developers: easier debugging, DOCUMENTATION!...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, helpers welcome :-)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-8981481737885658422?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/8981481737885658422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=8981481737885658422' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8981481737885658422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/8981481737885658422'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/07/mess-of-atfs-code.html' title='The mess of ATF&apos;s code'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-2459937406467822931</id><published>2009-06-23T08:19:00.002-04:00</published><updated>2009-06-23T08:29:39.190-04:00</updated><title type='text'>Technicians and schedules</title><content type='html'>Here I am, on the afternoon of a work day, sitting at home waiting for an eircom technician to come set it up my phone line. How nice. The story goes like this:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Two weeks ago, I placed an online order to request a phone line, explicitly specifying that the physical installation is already done (even though I don't know if it works or not, but that should be fairly easy for them to check). A few days later, the technician called me saying that he'd come today (two weeks after), anytime from 12.00 to 15.00, but that I'd call the company the same day to get a more accurate schedule.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Fine, I'll wait until the 23rd to do that call. But you know what happened, right? I called them this morning and they said that, effectively, the technician was coming today, from 12.30 &lt;i&gt;onwards&lt;/i&gt; but they were unable to provide me any more specific information because the technicians have &lt;i&gt;multiple appointments&lt;/i&gt;. What? Again, WHAT? At this age of technology, can't we implement a system to track technicians and their schedules? Can't we make some approximations of how long each visit will take? I bet it's trivial if you put in just some common sense.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;People have jobs, and they can't leave anytime for unknown periods of time; granted, I have some more freedom at Google, but that is absolutely not the case for most other companies. If you have to be at home at 12.30 sharp, and the appointment will last 30 minutes approximately, that is one thing, but having to be at home from 12.30 for an unexpected period of time, that is a very different thing.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Just wondering... couldn't they just make the technician call you about 20-30 minutes before arrival so that you could make the same arrangements as him and be there at the same time? It doesn't seem such an insane request.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-2459937406467822931?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/2459937406467822931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=2459937406467822931' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2459937406467822931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/2459937406467822931'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/06/technicians-and-schedules.html' title='Technicians and schedules'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-17885055.post-1880013018173418859</id><published>2009-06-21T13:40:00.006-04:00</published><updated>2009-06-22T17:21:37.974-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atf'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Child-process management in C for ATF</title><content type='html'>Let's face it: spawning child processes in Unix is a "mess". Yes, the interfaces involved (fork, wait, pipe) are really elegant and easy to understand, but every single time you need to spawn a new child process to, later on, execute a random command, you have to write quite a bunch of error-prone code to cope with it. If you have ever used any other programming language with higher-level abstraction layers — just check Python's subprocess.Popen — you surely understand what I mean.&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;The current code in ATF has many places were child processes have to be spawned. I recently had to add yet another case of this, and... enough was enough. Since then, I've been working on a C API to spawn child processes from within ATF's internals and just pushed it to the repository. It's still fairly incomplete, but with minor tweaks, it'll keep all the dirty details of process management contained in a single, one-day-to-be-portable module.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The interface tries to mimic the one that was designed on my Boost.Process Summer of Code project, but in C, which is quite painful. The main idea is to have a fork function to which you pass the subroutine you want to run on the child, the behavior you want for the stdout stream and the behavior you want for the stderr steam. These behaviors can be any of capture (aka create pipes for IPC communcations), silence (aka redirect to /dev/null), redirect to file descriptor and redirect to file. For simplicity, I've omitted stdin. With all this information, the fork function returns you an opaque structure representing the child, from which you can obtain the IPC channels if you requested them and on which you can wait for finalization.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is a little example, with tons of details such as error handling or resource finalization removed for simplicity. The code below would spawn "/bin/ls" and store its output in two files named ls.out and ls.err:&lt;/div&gt;&lt;pre&gt;static&lt;br /&gt;atf_error_t&lt;br /&gt;run_ls(const void *v)&lt;br /&gt;{&lt;br /&gt; system("/bin/ls");&lt;br /&gt; return atf_no_error();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static&lt;br /&gt;void&lt;br /&gt;some_function(...)&lt;br /&gt;{&lt;br /&gt; atf_process_stream_t outsb, errsb;&lt;br /&gt; atf_process_child_t child;&lt;br /&gt; atf_process_status_t status;&lt;br /&gt;&lt;br /&gt; atf_process_status_init_redirect_path(&amp;amp;outsb, "ls.out");&lt;br /&gt; atf_process_status_init_redirect_path(&amp;amp;errsb, "ls.err");&lt;br /&gt;&lt;br /&gt; atf_process_fork(&amp;amp;child, run_ls, &amp;amp;outsb, &amp;amp;errsb, NULL);&lt;br /&gt; ... yeah, here comes the concurrency! ...&lt;br /&gt; atf_process_child_wait(&amp;amp;child, &amp;amp;status);&lt;br /&gt;&lt;br /&gt; if (atf_process_status_exited(&amp;amp;status))&lt;br /&gt;     printf("Exit: %d\n", atf_process_status_exitstatus(&amp;amp;status));&lt;br /&gt; else&lt;br /&gt;     printf("Error!");&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;Yeah, quite verbose, huh? Well, it's the price to pay to simulate namespaces and similar other things in C. I'm not too happy with the interface yet, though, because I've already encountered a few gotchas when trying to convert some of the existing old fork calls to the new module. But, should you want to check the whole mess, &lt;a href="http://mtn-host.prjek.net/viewmtn/atf/revision/info/3ba2af4ab1cad67108c3fb1aea15e8e0168667ff"&gt;check out the corresponding revision&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17885055-1880013018173418859?l=blog.julipedia.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.julipedia.org/feeds/1880013018173418859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=17885055&amp;postID=1880013018173418859' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1880013018173418859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/17885055/posts/default/1880013018173418859'/><link rel='alternate' type='text/html' href='http://blog.julipedia.org/2009/06/child-process-management-in-c-for-atf.html' title='Child-process management in C for ATF'/><author><name>Julio Merino</name><uri>http://www.blogger.com/profile/08233346614736256024</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
