CppUTest TestPlugin changes

Share


I've recently made some very kewl CppUTest changes (at least, I think they are nice). CppUTest has a TestPlugin design. This means that you can write "Plugins" and add them in your main method. The Plugins is called before every setup and after ever teardown (automatically). This enables you to add general checking of things and works especially well with stubbing out some of the OS things.

Let me give some better example. For some embedded project I wrote some MutexPlugin. We stubbed out all the mutex locks and unlocks in the unit tests. Then, instead of doings mutex locks, I'd record the lock plus filename, linenumber (using macro magic and __FILE__ and __LINE__). Then I wrote the MutexPlugin which checks the the records to see if there is no inconsistency (dangling mutex, double locked mutex etc).

Then we'll install the Plugin in the main like this:

MutexPlugin mutexPlugin;
TestRegistry::getCurrentRegistry()->installPlugin(&mutexPlugin);

Now every test you ever write will automatically have mutex consistency checking and will fail automatically if there is something not consistent. Now... this is nothing new, we added this support to CppUTest already some time ago. However, now I added support for command line options to the TestPlugin. So, via command line, you can pass options to your Plugin by the -p option (CppUtest will pass all the -p options to all the installed plugins to see if they know what they mean, if none uses them then it will report an error).

So,  what you can do with this? Well, if we take our MutexPlugin as example, we can add a -pMutexVerbose option to the plugin which will output all the mutex locks and unlocks (again, plus line and file). That's a rather handy debugging and profiling option (especially combined with the -n option to run just one test). I did the same with the MemoryLeak plugin, so that you can dump all the dynamic memory allocations on your screen by just adding a command line option. (didn't check this in yet!)

The TestPlugin code is in souceforge. Some code (related to help options) is still missing, need to add that later.

Read more

Distributed Decision Making

Distributed Decision Making

ในองค์กรใหญ่ ๆ อะไร ๆ ก็ช้าลงไปหมด และสิ่งที่ช้าที่สุดคือการตัดสินใจนี่แหละครับ การตัดสินใจกระจายอยู่ในทุก ๆ อณูขององค์กร องค์กรที่มีบรรยากาศสบาย ๆ ทุกคนรู้สึกปลอดภัย ใคร ๆ ก็จะกล้าตัดสินใจและกล้าออกความเห็น แต่พอองค์กรใหญ่

By Chokchai
Risk Management: The Hard Test

Risk Management: The Hard Test

ท้ายหนังสือ Slack: Getting Past Burnout, Busywork, and the Myth of Total Efficiency ของ Tom DeMarco ได้ให้เทคนิคใหม่ในการจัดการความเสี่ยงกับผม ทอมสอนว่าในการทำงานยุคปัจจุบัน งานมีความเสี่ยงกระจายอยู่เต็มไปหมด ซึ่งในความเสี่ยงนั้น เรามีโอกาสโชคดีและมีโอกาสโชคร้าย การจัดการความเสี่ยงเป็นสิ

By Chokchai
วิธีปรับเวลาการนอน

วิธีปรับเวลาการนอน

ผมเดินทางกลับมาจาก Conference ของ Berkeley ที่ซานฟรานซิสโก เครื่องลงที่สนามบินสุวรรณภูมิประมาณ 22:30 น. กว่าจะถึงบ้านก็เกือบเที่ยงคืน ยังดีที่ขากลับไม่เหนื่อยเท่าขาไป เพราะลองซื้อหมอนรองคอจาก Duty Free ที่ซานฟรานซิสโกมาใช้ดู หมอนเป็นลายการ์ตูน มีรูปสะพาน

By Chokchai
เร็วแค่ไหนก็ไร้ค่า ถ้าไปผิดทาง

เร็วแค่ไหนก็ไร้ค่า ถ้าไปผิดทาง

อีกบทเรียนที่ผมได้จากหนังสือ Slack: Getting Past Burnout, Busywork, and the Myth of Total Efficiency ของ Tom DeMarco คือ ทำไมองค์กรใหญ่ ๆ ถึงยึดมั่นกับ Efficiency กันนัก Efficiency คืออะไร? Efficiency แปลว่า "ประสิทธิภาพ" ยกตัวอย่างเช่น

By Chokchai