you can logoff, but you can never leave

Thunderbolt to VGA Adapter on Linux

| Comments

I’ve previously written about my Thunderbolt to Ethernet adapter working on Linux despite claims that it should not. Recently I’ve used my MacBook to do a presentation and the Thunderbolt to VGA adapter worked well enough.

It was an Acer adapter but I have no more details b/c it wasn’t mine.

Before the event I’ve tested it and it worked so on the day of the event I’ve freshly rebooted my laptop to be sure no crashed processes or anything like that was running and gave it a go.

First time I plugged in the MacBook everything worked like a charm. Then my computer was unplugged and the lid closed, causing it to suspend. The second time I’ve plugged it in I was told there was nothing showing on the projector so I quickly plugged the adapter out and then back in. It worked more or less.

At the time I had LibreOffice Impress in presentation mode but I did see ABRT detecting a kernel problem. When my slides popped up the text on the first one was mostly missing but the rest were ok!

Mind you I’m still running RHEL 7 on my MacBook Air. The above is with kernel-3.10.0-229.14.1.el7.x86_64.

Unit Testing Example - Bad Stub Design in DNF

| Comments

In software testing, usually unit testing, test stubs are programs that simulate the behaviors of external dependencies that a module undergoing the test depends on. Test stubs provide canned answers to calls made during the test.

I’ve discovered an improperly written stub method in one of DNF’s tests:

class DownloadCommandTest(unittest.TestCase):
    def setUp(self):
        def stub_fn(pkg_spec):
            if '.src.rpm' in pkg_spec:
                return Query.filter(sourcerpm=pkg_spec)
                q = Query.latest()
                return [pkg for pkg in q if pkg_spec ==]

        cli = mock.MagicMock()
        self.cmd = download.DownloadCommand(cli)
        self.cmd.cli.base.repos = dnf.repodict.RepoDict()

        self.cmd._get_query = stub_fn
        self.cmd._get_query_source = stub_fn

The replaced methods look like this:

    def _get_query(self, pkg_spec):
        """Return a query to match a pkg_spec."""
        subj = dnf.subject.Subject(pkg_spec)
        q = subj.get_best_query(self.base.sack)
        q = q.available()
        q = q.latest()
        if len( == 0:
            msg = _("No package " + pkg_spec + " available.")
            raise dnf.exceptions.PackageNotFoundError(msg)
        return q

    def _get_query_source(self, pkg_spec):
        """"Return a query to match a source rpm file name."""
        pkg_spec = pkg_spec[:-4]  # skip the .rpm
        nevra = hawkey.split_nevra(pkg_spec)
        q = self.base.sack.query()
        q = q.available()
        q = q.latest()
        q = q.filter(, version=nevra.version,
                     release=nevra.release, arch=nevra.arch)
        if len( == 0:
            msg = _("No package " + pkg_spec + " available.")
            raise dnf.exceptions.PackageNotFoundError(msg)
        return q

As seen here stub_fn replaces the _get_query methods from the class under test. At the time of writing this has probably seemed like a good idea to speed up writing the tests.

The trouble is we should be replacing the external dependencies of _get_query (other parts of DNF essentially) and not methods from DownloadCommand. To understand why this is a bad idea check PR #113, which directly modifies _get_query. There’s no way to test this patch with the current state of the test.

So I took a few days to experiment and update the current test stubs. The result is PR #118. The important bits are the SackStub and SubjectStub classes which hold information about the available RPM packages on the system. The rest are cosmetics to fit around the way the query objects are used (q.available(), q.latest(), q.filter()). The proposed design correctly overrides the external dependencies on dnf.subject.Subject and self.base.sack which are initialized before our plugin is loaded by DNF.

I must say this is the first error of this kind I’ve seen in my QA practice so far. I have no idea if this was a minor oversight or something which happens more frequently in open source projects but it’s a great example nevertheless.

For those of you who’d like to get started on unit testing I can recommend the book The Art of Unit Testing: With Examples in .Net by Roy Osherove!

4000+ Bugs in Fedora - Checksec Failures

| Comments

In the last week I’ve been trying to figure out how many packages conform to the new Harden All Packages policy in Fedora!

From 46884 RPMs, 17385 are ‘x86_64’ meaning they may contain ELF objects. From them 4489 are reported as failed checksec.

What you should see as the output from checksec is

Full RELRO      Canary found      NX enabled    PIE enabled     No RPATH   No RUNPATH
Full RELRO      Canary found      NX enabled    DSO             No RPATH   No RUNPATH

The first line is for binaries, the second one for libraries b/c DSOs on x86_64 are always position-independent. Some RPATHs are acceptable, e.g. %{_libdir}/foo/ and I’ve tried to exclude them unless other offenses are found. The script which does this is checksec-collect.

Most often I’m seeing Partial RELRO, No canary found and No PIE errors. Since all packages potentially process untrusted input, it makes sense for all of them to be hardened and enhance the security of Fedora. That’s why all of these errors should be considered valid bugs.

Attn package maintainers

Please see if your package is in the list and try to fix it or let me know why it should be excluded, for example it’s a boot loader and doesn’t function properly with hardening enabled. The full list is available at GitHub.

For more information about the different protection mechanisms see the following links:

UPDATE 2015-09-17

I’ve posted my findings on fedora-devel and the comments are more than interesting even revealing an old bug in libtool.

Minor Typo Bug in Messenger for bg_BG.UTF-8

| Comments

Messenger typo

There’s a typo in the Bulgarian translation of It is highlighted by the red dot on the picture.

hunspell easily catches it so either Facebook doesn’t run their translations through a spell checker or their spell checker is borked.

Pedometer Bug in Samsung S Health

| Comments

Do you remember the pedometer bug in Samsung Gear Fit I’ve discovered earlier ? It turns out that Samsung is a fan of this one and has the exact same bug in their S Health application.

The application doesn’t block pedometer(e.g. steps counting) while performing other activities such as cycling for example. So in reallity it reports incorrect value for burned callories. At this time I call it bad software development practice/architecture on Samsung’s part which leads to this bug being present.

Btw for more interesting bugs see Samsung Gear Fit Bug-of-the-Day.

Tip: Try F10 When Editing Grub2 Menu in EFI Mode

| Comments

When editing the grub2 menu (especially in EFI mode) it tells you to press Ctrl-x to save your changes and continue the boot process. However this doesn’t work on Apple hardware (rhbz#1253637) and maybe some other platforms. If this is the case try pressing F10 instead. It works for me!

Call for Ideas: Graphical Test Coverage Reports

| Comments

If you are working with Python and writing unit tests chances are you are familiar with the coverage reporting tool. However there are testing scenarios in which we either don’t use unit tests or maybe execute different code paths(test cases) independent of each other.

For example, this is the case with installation testing in Fedora. Because anaconda - the installer is very complex the easiest way is to test it live, not with unit tests. Even though we can get a coverage report (anaconda is written in Python) it reflects only the test case it was collected from.

coverage combine can be used to combine several data files and produce an aggregate report. This can tell you how much test coverage you have across all your tests.

As far as I can tell Python’s coverage doesn’t tell you how many times a particular line of code has been executed. It also doesn’t tell you which test cases executed a particular line (see PR #59). In the Fedora example, I have the feeling many of our tests are touching the same code base and not contributing that much to the overall test coverage. So I started working on these items.

I imagine a script which will read coverage data from several test executions (preferably in JSON format, PR #60) and produce a graphical report similar to what GitHub does for your commit activity.

See an example here!

The example uses darker colors to indicate more line executions, lighter for less executions. Check the HTML for the actual numbers b/c there are no hints yet. The input JSON files are here and the script to generate the above HTML is at GitHub.

Now I need your ideas and comments!

What kinds of coverage reports are you using in your job ? How do you generate them ? How do they look like ?

Open Data Event Coming to Sofia

| Comments

Open Data and Intelligent Government is the name of upcoming event organized by Sofia Tech Park on July 14th.

The (preliminary) topics for this event are:

  • Government vision for opening data;
  • Presentation of national platform for open data;
  • Legal aspects of open data;
  • Presentation of Bulgarian open data portal;
  • Europe and open data;
  • Open, coordinated e-government for citizens and business;
  • What has already been done by municipalities in Bulgaria;
  • Strategy of Sofia municipality for open data;
  • Upcoming open data programming contest organized by Sofia municipality.

I will also be participating in this event by covering two topics I’m close to:

  • Entrepreneurship and open data - sharing my limited experience with Difio and processing open data;
  • Technical tips for successful open data hackathon - sharing my observations as a mentor at HackFMI and giving some recommendations which will help the alleged open data contest make a difference not being just another dull event organized by governmental agencies.

So far other confirmed speakers are Rado from HackBulgaria/ HackFMI and which are working in the field of open government and open data.

I’m also in touch with the event organizers and helping a little bit with the program. If you’re interested in speaking please get in touch with me ASAP.

DEVit Conf 2015 Impressions

| Comments

It’s been a busy week after DEVit conf took place in Thessaloniki. Here are my impressions.

Crack, Train, Fix, Release


I’ve started the day with the session called “Crack, Train, Fix, Release” by Chris Heilmann. While it was very interesting for some unknown reason I was expecting a talk more closely related to software testing. Unfortunately at the same time in the other room was a talk called “Integration Testing from the Trenches” by Nicolas Frankel which I missed.

At the end Chris answered the question “What to do about old versions of IE ?”. And the answer pretty much was “Don’t try to support everything, leave them with basic functionality so that users can achieve what they came for on your website. Don’t put nice buttons b/c IE 6 users are not used to nice things and they get confused.”

If you remember I had a similar question to Jeremy Keith at Bulgaria Web Summit last month and the answer was similar:

Q: Which one is Jeremy’s favorite device/browser to develop for.
A: Your approach is wrong and instead we should be thinking in terms of what features are
essential or non-essential for our websites and develop around features
(if supported, if not supported) not around browsers!

Btw I did ask Chris if he knows Jeremy and he does.

After the coffee break there was “JavaScript ♥ Unicode” by Mathias Bynens which I saw last year at How Camp in Veliko Tarnovo so I just stopped by to say hi and went to listen to “The future of responsive web design: web component queries” by Nikos Zinas. As far as I understood Nikos is a local rock-star developer. I’m not much into web development but the opportunity to create your own HTML components (tags) looks very promising. I guess there will be more business coming for Telerik :).

I wanted to listen to “Live Productive Coder” by Heinz Kabutz but that one started in Greek so I switched the room for “iOS real time content modifications using websockets” by Benny Weingarten-Gabbay.

After lunch I went straight for “Introduction to Docker: What is it and why should I care?” by Ian Miell which IMO was the most interesting talk of the day. It wasn’t very technical but managed to clear some of the mysticism around Docker and what it actually is. I tried to grab a few minutes of Ian’s time and we found topics of common interest to talk about (Project Atomic anyone?) but later failed to find him and continue the talk. I guess I’ll have to follow online.

Tim Perry with “Your Web Stack Would Betray You In An Instant” made a great show. The room was packed, I myself was actually standing the whole time. He described a series of failures across the entire web development stack which gave developers hard times patching and upgrading their services. The lesson: everything fails, be prepared!

The last talk I visited was “GitHub Automation” by Forbes Lindesay. It was more of an inspirational talk, rather than technical one. GitHub provides cool API so why not use it?


DEVit team

From what I know this is the first year of DEVit. For a first timer the team did great! I particularly liked the two coffee breaks before lunch and in the early afternoon and the sponsors pitches in between the main talks.

All talks were recorded but I have no idea what’s happening with the videos!

I will definitely make a point of visiting Thessaloniki more often and follow the local IT and start-up scenes there. And tonight is Silicon Drinkabout which will be the official after party of DigitalK in Sofia.

Free Software Testing Books

| Comments

There’s a huge list of free books on the topic of software testing. This will definitely be my summer reading list. I hope you find it helpful.

200 Graduation Theses About Software Testing

The guys from QAHelp have compiled a list of 200 graduation theses from various universities which are freely accessible online. The list can be found here.

Why Does Sysctl Not Write Under /sys

| Comments

Recently I’ve been looking into fixing tilde and Fn keys mapping for MacBook Air and thought I could use sysctl to permanently set the desired values. Unfortunately this is not possible. sysctl can only write under /proc/sys and this is hard-coded in the source:

static const char PROC_PATH[] = "/proc/sys/";

IMO this is relatively easy to patch and allow sysctl to read/write values under /sys. The only open question I see is backward compatibility - maybe adding new parameter (e.g. –sysfs) or adding extended sytax e.g. if variable name starts with / then treat it as absolute path.

I’ve asked sysctl maintainers on the procps mailing list but so far got no answer.

Is anyone else interested in this? How do you set parameter values under /sys then ?

NOTE: for my particular purposes I could have used config files under /etc/modprobe.d/ or a startup script (I used that) instead.

Using USB to VGA Adapter on MacBook Air With Linux

| Comments

A quick solution for MacBook Air users running Linux who want to use external projector is to use a USB to VGA adapter. Mine is Plugable UGA-165 and it works great with Red Hat Enterprise Linux 7.1.

After the device is plugged in the udl kernel module is loaded and a new framebuffer device is created (/dev/fb1 in my case). Using mate-display-properties I’m able to configure the 2nd monitor attached to the USB video card. I was able to succeffully display an OpenOffice presentation on the 2nd monitor and play YouTube video.

All USB 2.0 devices from Plugable should be well supported on Linux. For USB 3.0 David Airlie from Red Hat is doing some reverse engineering but I have no idea what the status is. For more info see:

Thunderbolt to Ethernet Adapter on Linux

| Comments

As it seems my Thunderbolt to gigabit Ethernet adapter works with RHEL 7 on a MacBook Air despite some reports it may not.

After plugging the device is automatically recognized and the tg3 driver is loaded. Detailed lspci below:

0a:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM57762 Gigabit Ethernet PCIe
    Subsystem: Apple Inc. Device 00f6
    Physical Slot: 9
    Flags: bus master, fast devsel, latency 0, IRQ 19
    Memory at cd800000 (64-bit, prefetchable) [size=64K]
    Memory at cd810000 (64-bit, prefetchable) [size=64K]
    [virtual] Expansion ROM at cd820000 [disabled] [size=64K]
    Capabilities: [48] Power Management version 3
    Capabilities: [50] Vital Product Data
    Capabilities: [58] MSI: Enable- Count=1/8 Maskable- 64bit+
    Capabilities: [a0] MSI-X: Enable+ Count=6 Masked-
    Capabilities: [ac] Express Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [13c] Device Serial Number 00-00-ac-87-a3-25-20-33
    Capabilities: [150] Power Budgeting <?>
    Capabilities: [160] Virtual Channel
    Capabilities: [1b0] Latency Tolerance Reporting
    Kernel driver in use: tg3

Unplugging and pluggin back in the network cable works as expected. I did see my computer freeze 2 out of 10 times when I’ve unplugged the Thunderbolt adapter but couldn’t reproduce it repliably or grab more info.

For the record this is with kernel 3.10.0-229.1.2.el7.x86_64 which is missing this upstream commit. I’m not sure why it works though.

If I remember correctly tg3 is available during installation so you should be able to use the Thunderbolt adapter instead of WiFi as well.

Compiling Twinkle SIP Phone on RHEL 7

| Comments

One of the best SIP clients for Linux is Twinkle. However upstream is not active (or even maybe dead) and the package is missing from latest Fedora releases and fails to build on RHEL 7.

First you need to build and install a few dependencies in the following order: ucommon, ccrtp, libzrtpcpp. You will also need EPEL 7 enabled to satisfy build dependencies.

Then apply the following patch to the original twinkle.spec

--- twinkle.spec.orig   2015-05-01 14:07:01.870710147 +0300
+++ twinkle.spec    2015-05-01 15:07:28.734734573 +0300
@@ -47,6 +47,8 @@

 export LDFLAGS=-lkio 
+export CPPFLAGS="$CPPFLAGS -I/usr/include/libzrtpcpp/" 
 make %{?_smp_mflags}

The package now builds, installs and runs successfully on RHEL 7. The compiled packages and dependencies are available in my Macbook Air RHEL 7 repository.

Fixing Tilde and Function Keys Mapping for MacBook Air on Linux

| Comments

Thera are two problems with the MacBook Air keyboard on Linux:

Function keys and media keys are switched and by default you have to press Fn+F5 in order to refresh a browser page. The solution is

echo 2 > /sys/module/hid_apple/parameters/fnmode

The tilde key is mapped improperly, see RHBZ #1025041. To fix it

echo 0 > /sys/module/hid_apple/parameters/iso_layout

Permanent fix

Either you have to add the above commands in a boot script or you can yum install mba-kbd-fix from my Macbook Air RHEL 7 repository. The RPM source can be found here.

RHEL 7 Repository for MacBook Air

| Comments

I’ve made a repository with binary (x86_64 only) and source RPM packages which are missing from Red Hat Enterprise Linux 7 and necessary when using a MacBook Air. To install execute the commands below:

cd /etc/yum.repos.d/

Wireless driver

yum install kmod-wl

Display backlight driver

yum install kmod-mba6x_bl

And uncomment /etc/X11/xorg.conf.d/98-mba_bl.conf.

Note: the .spec file is available from RP #26.

Fixing keyboard mapping

yum install mba-kbd-fix

Fixing Display Brightness on MacBook Air With RHEL 7

| Comments

One issue with RHEL/CentOS/Fedora on MacBook Air laptops is brightness control and backlight behavior after suspend/resume. I’ve found the solution here and only tweaked it slightly for my use case.

mba6x_bl doesn’t load automatically

The reason being the driver matches older hardware:

$ modinfo mba6x_bl
filename:       /lib/modules/3.10.0-229.1.2.el7.x86_64/extra/mba6x_bl/mba6x_bl.ko
alias:          dmi:*:pnMacBookAir6*
license:        GPL
description:    MacBook Air 6,1 and 6,2 backlight driver
author:         Patrik Jakobsson <>
rhelversion:    7.1
srcversion:     4D069C8EB0E470AF27E7F8D
depends:        video
vermagic:       3.10.0-229.1.2.el7.x86_64 SMP mod_unload modversions 

My system is MacBookAir7,2 and doesn’t match the module alias. So a quick fix was needed. For more info about MODULE_ALIAS see ArchWiki. Alternatively on Red Hat based systems you can place a config file under /etc/sysconfig/modules, see the docs for more details.

intel_backlight driver is in the way

On older systems mba6x_bl doesn’t get used automatically. The problem is the offending intel_backlight driver which gets used instead. To workaround it add this xorg.conf snippet:

$ cat /etc/X11/xorg.conf.d/98-mba_bl.conf
Section "Device"
    Identifier      "Intel Graphics"
    Driver          "intel"
    Option          "Backlight"     "mba6x_backlight"

For more info see RHBZ 989555.

Everything in one go

If you are using RHEL 7 or CentOS 7 (version 7.1 required) instead of Fedora you can take a look at my Macbook Air RHEL 7 repository.

Disabling MacBook Startup Sound in Linux

| Comments

There is an easy way to disable the MacBook startup sound (boot chime) even after wiping out OS X and installing Linux.

This sound can be easily disabled if you mute the volume in OS X and shutdown the computer. The value is stored in NVRAM.

  1. Reboot the computer and hold Cmd+Alt(Option)+R. This will start OS X Internet recovery mode;
  2. Open the terminal and issue the following command

     nvram SystemAudioVolume=%00
  3. Reboot.

Voila. In Linux try this:

# efivar -l | grep SystemAudioVolume

# efivar -n 7c436110-ab2a-4bbb-a880-fe41995c9f82-SystemAudioVolume -p
GUID: 7c436110-ab2a-4bbb-a880-fe41995c9f82
Name: "SystemAudioVolume"
    Boot Service Access
    Runtime Service Access
00000000  00                                                |.               |

# efivar -n 7c436110-ab2a-4bbb-a880-fe41995c9f82-SystemAudioVolumeDB -p
GUID: 7c436110-ab2a-4bbb-a880-fe41995c9f82
Name: "SystemAudioVolumeDB"
    Boot Service Access
    Runtime Service Access
00000000  00 

Note 1: Before disabling both variables had non zero values. Also SystemAudioVolumeDB doesn’t seem to have any effect.

Note 2: RHEL or CentOS users need to rebuild efivar from the Fedora src.rpm.

Note 3: several Internet sources suggest that writing EFI variables from Linux may sometimes corrupt your Apple firmware. I didn’t research this any further. If you happen to figure out how to successfully write to these variables under Linux please let everyone know in the comments (in case OS X recovery mode goes missing, you know).

Thanks to my reader Alexander, who gave me the hint in a previous blog post.