Friday, February 07, 2014

Difference between view source and view element in chrome

Introduction

Right-Clicking on a page in Google Chrome shows up a context menu. This context menu has two options -

  1. View Page Source
  2. Inspect Element

The Difference between the two

I had always assumed that these are same html "code", but they are no. View Page Source gives you the raw page source. Inspect Element gives you the rendered code. That's a key difference! 
Consider the case of an JS script that updates the DOM dynamically. Looking at the page source, we only see the script code or the link to it. Inspect element however shows the updated DOM! So, it's an easy and simple way to understand your updated DOM. 

Sunday, January 26, 2014

Test Automation requires constant maintenance

Introduction

We spent the greater part of a decade working on a Test Automation system. That time spent was one of great productivity and really enjoyable. However, the question is what should a test automation focus on keeps coming back. Should one write a system that incorporates test reporting, scheduling, simple UI etc.. or should one write test cases that are effective? Obviously everyone wants test cases but there is always pressure to make the reports look 'nice', make it simple so that even the CEO's assistant can run it!

Test Automation in TCL/TK

The first system we wrote was in TCL/TK and used XML to configure different test suites, tests, and parameters. Using TCL/Expect, it automated interactions with a SoC on a board via a serial interface. It was designed to test Linux and RTOS network drivers. However, the interfaces kept changing and it really didn't do what we wanted to. The only place it made sense was the performance and long duration tests where it was hooked up to an IXIA network simulator and controlled network traffic.

Test Automation in Ruby

The second system was written simply because a PHB at the top of the corporate ladder decided that we can get better 'efficiency' if all the test automation teams worked together to write a comprehensive one-shoe-fits-all system. Our counterparts had used Ruby and it seemed pretty cool option to try. This system needed work for testing RTOS'es, Linux drivers, Multimedia frameworks, Compilers, SDKs and the Kitchen Sink. After all, the PHBs thought, testing is a single domain and everything else is incidental. The big problem was that we needed to talk to teams the other side of the world everyday to do anything useful. The project management was a nightmare and we ended writing a lite version of the software which is still being used.

Costs

Looking back I would say we spent the following
  1. 4 resources worked full time for 10 years on test automation with us. That's 4800 days spent on building, maintaining and enhancing an internal tool.
  2. Effort spent was 9600 person days on an average. There were times when we had more people working on the project but really that doesn't matter.
  3. Assuming that each resource was billed $4000 per month that works out to $20 per hour. A low figure I picked on purpose so that we are conservative in our cost estimate.
  4. It works out $192000 at a minimum. If we are being realistic, then $100 per hour is probably the right ballpark number. 
So, I would estimate that its atleast $960000 spent on test automation frameworks. This is a cost separate from actual test case implementation, test execution, project management, managing expectations, vendor management, outsourcing management etc..

Summary

My advice - don't spend too much test frameworks, test automation systems. Instead focus on the actual tests. Focus on automating your tests with simple scripts and don't worry too much about tying them all together. Is it better to have a beautiful system with few tests, great reporting, fantastic UI OR a large bank of tests, crummy reports and command-line runners? The latter gives you better bang for the buck for sure. End of the day, XKCD sums it up neatly.

Sunday, January 05, 2014

Google Apps Marketplace

Introduction

Google Apps has a marketplace which hosts apps (not to be confused by Google App Engine). That means you can develop applications that sit on top of Google Apps like Gmail, Docs etc.. The real implication of this is that it converts Google Apps to a platform for development, opening the doors for interesting applications. Everything from Business apps to simple ToDo lists are now on Chrome and can be tied to Google Drive.

Development

The starting point for development on Google Apps is https://developers.google.com/google-apps/. The only weird thing is the $5 upfront payment in order to start developing. After that, its similar to developing a Chrome extension or an App.

Wednesday, December 04, 2013

ultrahaptics for handsfree feedback

Introduction

Ultrahaptics is the name that a team in Bristol University is calling their touchless feedback system. Haptics is the term used to describe tactile feedback like a vibrating joystick or a force feedback joystick. In the case of ultrahaptics, the feedback is via focussing audio waves to a point. From what I understood, they do this by focusing sound waves using a phased transducer array.

This makes it really cool because now you get feedback without having to touch something.

Applications of Ultrahaptics

I can think of several applications for this kind of technology, the first of which is definitely console games. Imagine hooking this up with Kinect! So, here's my list of places where I would like to see this.
  1. Mashup with Kinect.
  2. Digital Signs and Kiosks. Right now the only way is to the touch the screen.
  3. Phones and Tablets. I'm not fully sure of this one, but maybe.

Linux Device Drivers for Ultrahaptics

I don't know if there are any Linux drivers written for this. From the video, it looks like the ultrahaptics array is hooked up to a Mac. If this makes the mainstream, then definitely someone will sit down and write drivers for it. There are several things they will need to take care of There are USB Joystick drivers today and they provide both control and feedback. This would be something similar. However, the userspace will also need to keep up. evdev would need to provide event notification for applications and they will need to use some ioctl to control the 'feel' of the 'screen'. All in all very interesting.

Friday, November 29, 2013

How to build and setup LLVM Scan Analyzer for Linaro Toolchain

Downloading and Installing Clang-Analyzer

Download LLVM, Clang, Clang-tools-extra and Compiler-RT from - http://llvm.org/releases/download.html.

  1. Extract the LLVM tarball. I'm going to use the variable LLVM to point to this directory going forward.
  2. Go to $LLVM/tools/src. Extract the clang release tarball. Rename the extracted directory as clang
  3. Go to $LLVM/tools/src/clang/tools/. Extract the clang-tools-extra and rename it as extra.
  4. Go to $LLVM/projects/. Extract the compiler-rt tarball and rename it as compiler-rt.
Note! - If you don't extract the clang, clang-tools-extra and compiler-rt in the respectively directories, it will not build them by default.

For more information look at http://clang.llvm.org/get_started.html. The instructions are for svn but they apply for the release tarballs as well.

Building and Installing Clang

Go to $LLVM directory and then you can configure, build and install clang.
 $ ./configure $ make $ make install
If you want to install clang in a specific directory then pass --prefix= to configure. Usually, I use /proj/staging/ to stage my builds and so, I usually build as ./configure --prefix=/proj/staging/llvm

Note! make install will not install scan-build and scan-view. They remain in $LLVM/tools/clang/tools/scan-build and $LLVM/tools/clang/tools/scan-view. So you will need to add these directories into your path.

Downloading and Installing Linaro Toolchain

Download Linaro Toolchain from - https://launchpad.net/linaro-toolchain-binaries/. Extract it to a directory of choice. I usually place it in /proj/staging/linaro-gcc. Next add the /proj/staging/linaro-gcc/bin directory to your PATH variable.

Running clang-analyzer with linaro toolchain

Now follow usual steps to cross compile your program. To enable scan-build make sure you run make via scan-build as shown in my previous post on running clang-analyzer.

Monday, November 18, 2013

Running a custom PHP application on the Bitnami Wordpress stack

Being an embedded software engineer, I usually go a bit spaced out when reading about things like wordpress, bitnami stacks etc.. I have dabbled on making small intranet sites with Ruby on Rails but have never looked at PHP.

Today, I downloaded a wordpress installer from bitnami and 10 minutes later I had a small site running on my laptop. I had a look at the various plugins and installed a couple as well.

Intrigued, I wanted to spend a little time learning PHP. So, I created a custom app by following the instructions from Bitnami's Wiki topic and started reading the tutorial from w3cschools. So far PHP doesn't seem very complex and I'm being to understand why it's so popular.

Steps to create a custom app


  1. Create a new folder in the apps directory, say 'test'.
  2. Copy over the conf folder from the wordpress directory into the apps/test folder. We will need to edit the configurations inside them
  3. Search and replace 'wordpress' with 'test'. Typically, these are directory paths
  4. Create a htdocs folder in apps/test. This will hold our application. For now create an index.php and echo a 'Hello World'.
  5. Now, we need to edit the apache server configuration files so that they can find the app. Bitnami makes it quite simple by keeping a configuration file in apache2/conf/bitnami with the name bitnami-apps-prefix.conf. Edit this file and copy the line pointing to wordpress directory to a new line and change from 'wordpress' to 'test'.
  6. Restart Apache and that's it!

Thursday, March 21, 2013

Use git commits to understand code design

http://gitster.livejournal.com/30195.html has an excellent point about using --grep and other options such as --author --since to grep through commits to find information. One really good thing about Linux developers is the quality of the commits - very high.

I was reading up about omapdrm and wanted to find more information on GEM - Graphics Execution Manager. Now, most of the code for omapdrm has come from Rob and so, the easiest thing to understand about GEM is to run 'git log --grep=GEM --author=Rob' and boom! you get a design document (almost!). Add -p to the git log command and you get the code changes done as well.

On similar lines, reading code differences is a must. The patch format isn't really good for my brain, and I prefer seeing code differences side by side. The tool - Emacs of course, esp. ediff. Just visit any file and do a M-x ediff-revision. When choosing the revisions, you can pick anything that git rev-parse understands. This tip is brought to you by http://blog.endpoint.com/2009/03/emacs-tip-of-day-ediff-revision.html. A real life saver because my older flow used running vc-log and then visting a revision and finally running ediff-buffers. ediff-revision is much better.

Tuesday, March 05, 2013

make uImage in 3.9-rc1

With all the multiplatform support, make uImage no longer works in 3.9-rc1. There are two options - either pass LOADADDR to make uImage or run mkimage manually.

The other option is to compile uboot with zImage support and just use the zImage that's created.

For a pandaboard pass 0x80008000 as the LOADADDR

Monday, February 25, 2013

static analysis with llvm

Using Scan Build

LLVM comes with a static analyzer - http://clang-analyzer.llvm.org. It works by overriding CC. So, to use it with autoconf'ed project, you need to first run it when running configure and then make. On Ubuntu you can always apt-get it, but if you are interested in building from source then take a look at my other post.
$ scan-build ./configure
$ scan-build make
In some case, esp. if you are building from source, scan-build may not find clang. So you will need to explicitly, pass the path to clang to scan-build. E.g. if clang is installed (via make install) at /proj/staging/llvm, then you will need to pass --use-analyzer to scan-build.

$ scan-build --use-analyzer=/proj/staging/llvm/bin/clang ./configure
$ scan-build --use-analyzer=/proj/staging/llvm/bin/clang make

Integrating Clang Static Analyzer into Makefile.am

Alex has a different approach to running scan build. In this post, he shows how to include a step to run the analyzer in every build. This is really neat because there is no change to your standard build flow. Every time you run make, it automatically calls the analyzer (or not if you don't include the step to all-local).

The flip side is that you need to use clang as the compiler only and not gcc or any other compiler. 

More Details on Clang Static Analyzer

More details on LLVM's static analyzer is available at http://clang-analyzer.llvm.org/scan-build.html.

Example of a Bug that Clang Static Analyzer found

I ran scan-build against wayland source some time back and caught a bug immediately - https://bugs.freedesktop.org/show_bug.cgi?id=61385.

To incorporate Alex's idea, a small patch to src/Makefile.am is required. Just add the following changes to Wayland's src/Makefile.am and then rebuild. Note that you must use clang as the compiler in this case.

+analyzer_srcs =                                      \
+    $(filter %.c, $(libwayland_util_la_SOURCES))     \
+    $(filter %.c, $(libwayland_server_la_SOURCES))   \
+    $(filter %.c, $(libwayland_client_la_SOURCES))
+
+analyzer_plists = $(analyzer_srcs:%.c=%.plist)
+
+$(analyzer_plists): %.plist: %.c
+       @echo "  CCSA  " $@
+       @$(COMPILE) --analyze $< -o $@
+
+all-local: $(analyzer_plists)
+
+MOSTLYCLEANFILES = $(analyzer_plists)

Sunday, February 24, 2013

Linux News - Feb 24, 2013


1 Sony

  • Gamers rejoice - PS4 announced (shipping end of 2013) - http://www.wired.com/gamelife/2013/02/sony-liveblog/. Moving away from PS3's Cell Architecture (PowerPC) to a PC Architecture (AMD X86-64) with 8 GB RAM. GPU is AMD Radeon based which they claim can hit 1.84 Terflops. So, PS4 won't run PS3 Games I guess.

2 Linux

3 Minix

4 NetBSD

5 Voyager

Sunday, February 17, 2013

Installing Freebsd 9.1 on an USB Stick

If you want to evaluate Freebsd, then the quickest way to do that is by trying it out on with USB stick. However the download page does not have USB images and instead there is an ISO file to burn on a CD.

Here are my instructions for installing Freebsd on an USB memory stick. Tried and tested on Freebsd 9.1.

1. Download and install mfsbsd from http://bit.ly/1d4VpA2. Pick the usb image and flash to the USB stick that you want to use.
2. To flash the image on MacOS, run diskutil list to find the drive. Then run diskutil umountDisk diskX to umount all partitions on it. Finally run dd if=mfsbsd-9.1-RELEASE-i386.img of=/dev/rdiskX bs=4m to write the image to the USB Stick.
3. Reboot and boot from the USB Stick. This will drop you into the mfsbsd prompt. Goto /dev and see what daX devices are present. Use fdisk to figure out which one maps to your USB drive.
4. Now run bsdinstall from /usr/sbin. When choosing the location to install, pick the same daX device that maps to the USB Stick.
5. ????
6. Profit.

Linux News - Feb 17, 2013


1 Linux

1.1 Releases
1.2 Unix History
  • http://www.levenez.com/unix/ has a great view of how Unix has evolved from UNICS in 1969. QNX afficianados will appreciate how QNX started as QUNIX in 1980 and hit Beta in 1983. In comparision, the first Android Beta was in 2007 as a fork from 2.6.23. So, why is it important to look at Unix History? That's because most of the code in Linux is long-lived and the linux community takes backward compatibility very seriously!
  • There is a simplified version on Wikipedia - http://en.wikipedia.org/wiki/File:Unix_history-simple.png.  
2 QA and Testing

2.1 Trinity Fuzz Tester
2.2 QA on Ubuntu
2.3 Static Checker for Linux Kernel
2.4 SystemTap
2.5 UMockdev
3 Virtualization

3.1 Qemu
  • Qemu 1.4.0 released. Claims that a guest os can perform at 95% of native performance.
4 Driverless Car

Saturday, December 01, 2012

tracking patches and information overload

If you want to get into linux, in deep, then you must subscribe to different mailing lists. I have been a member of atleast a dozen mailing lists for sometime and you know what its almost impossible to read all the mail that comes your way.

This is where gmail-foo needs to save the day!

1. Organize by labels. Have labels for everything possible - patches, different mailing list, different topics etc..
2. Then use gmail's search to the extreme. Search for labels, unread mails, from: and subject: in combo. Read only what makes sense! Mark everything else as read or just delete them!

Even then its impossible to read all email. 

Saturday, November 17, 2012

Updates - Nov 17


1 News

1.1 Links

1.2 Releases

1.3 Industry

Tuesday, March 06, 2012

Does constantly compromising make you worse?

That's what Rocky says in his post - http://rockyj.in/?p=248. The corresponding Reddit thread is at http://www.reddit.com/r/programming/comments/qi9rd/musings_on_india_and_technology/.

There is one valid point - that we do compromise a lot when it comes to quality in India. As a product integrator, I spend a lot of time pulling in code from others. I do compromise a lot when it comes to the software delivered to me. It could schedule slips, shoddy documentation or just plain bad code. Yet, I take it all in with the hope that it will improve in time. Maybe I should stop doing that.

What I don't agree with Rocky is that there are *only* shoddy programmers in India because we compromise all the time. That's flat out wrong. There are some excellent programmers that I have worked with.

The flip side to compromising, is that I think India is *the* place for you support your customers. We can patch it, fix it, hack it, change it etc all in the goal of getting customers to production. I have seen this often. There is a different skill to getting software out of the door and shipping it to a customer. Its a very special skill to then get that software to integrate and work in the customer's stack.
Its one thing to write software that stands alone, but its a completely different thing to make it work with other peoples code. That's where the India brigade comes in.

Getting the software to work in a customer's world. While shoddy programmers in India will still struggle, the good ones will get that software to bend and work. If it means compromising on longer term quality to get a customer to production, so be it.

Sunday, February 19, 2012

Ubuntu Core - Alpha2 with both armel and armhf

I didn't expect it, but armhf seems to be part of ubuntu-core for precise. That's pretty surprising because I remembering seeing a number of packages that didn't build for armhf about a month back.

Nevertheless, its good if armhf and armel is part of ubuntu-core. The only question is whether we will get all the community supported packages on both or only Cannonical ones? I'm specifically interested in not running Unity and much rather have LXDE running. The only question is whether there will be LXDE armhf packages in addition to armel ones.

Sunday, February 05, 2012

Aquamacs vs. Emacs


Aquamacs does seem more natural than the standard Emacs.

I'm a new Mac user switching over from a PC and having emacs is a must. What Aquamacs does is make emacs more OSX oriented. While this can be confusing, especially if you are coming from Linux (like, I am) in general things seem ok.

The font is better for sure. More reviews to follow as I test things out.

Saturday, February 04, 2012

OSX Emacs Drag and Drop


By default, I find that drag and drop on OSX does not work in the same way that it would on Windows. On Windows, a new buffer is created. On OSX, the file is opened in the same buffer. Googling around gave me - http://stackoverflow.com/questions/1850292/emacs-23-1-and-mac-os-x-problem-with-files-drag-and-drop.

Adding the following text worked fine -

Sunday, December 18, 2011

An unscientific comparision of different tiling window managers

I was intrigued by tiling window managers and decided to try using them. If you don't know what they are, here's the wikipedia page - http://en.wikipedia.org/wiki/Tiling_window_manager

I spent Saturday installing and trying them on out on my ubuntu box. Since I run ubuntu on a virtual box, unity is very sluggish. I explored StumpWM, DWM, Bluetile and finally Awesome.

StumpWM

I started with StumpWM because I drawn by its implementation. Its implemented in Common Lisp and that was very interesting to me. It means we can change stuff around and they will instantly appear and be accessible.

DWM

DWM is the granddaddy of all Tiling Window Managers. Its the antithesis of StumpWM because nothing is configurable. You want to change something? Modify the code and rebuild it.

Bluetile

Bluetile is very user friendly. Its built on top of xmonad but the key difference is that unlike xmonad you don't have to install a full Haskell development environment. Configuration is limited to a few items only. 

Awesome

And finally Awesome. What can I say? Its really awesome! Highly configurable, with a number of layouts, themes and yet quite thin.

Implementation

  1. StumpWM - Common Lisp. This makes is very configurable and changes are instantaneous. Unfortunately you need to download and install a CL implementation and a couple of libraries.
  2. DWM - Straight up C. Less than 2000 lines of code. 
  3. Bluetile - Haskell. 
  4. Awesome - C and Lua. Lua makes configuration easy and that part of the Awesome if very well documented. 

Dynamic or Manual

  1. StumpWM - Manual. It means you need to place windows by yourself. After trying the others, I found this to be a little painful because the point of tiling is productivity. If you have to set things up yourself, then you lose that part.
  2. DWM - Dynamic.  It sets up the layout for you
  3. Bluetile - Dynamic with a couple of different layouts to choose from. Its also very easy to switch between the layouts
  4. Awesome - Dynamic with a number of different layouts and tiling algorithms. 

Conclusion

  1. StumpWM - I didn't like it that much unfortunately because placement is manual and it seems very "raw". Its very closely tied to Emacs and Screen philosophy and so even the prefix key by default is CTRL-T. The best part is that it uses CL and so, you can change things, add new commands/shortcuts without restarting stuff. The sky's the limit for the things you can do, but its elitist in the sense you need to understand common lisp to do that. Its not a problem for me but that may not appeal to everyone.
  2. DWM - Very minimal. As long as you don't fight the flow its great. Unfortunately, I had to read the code to understand what the different shortcut keys. I even uninstalled it because I didn't know how to start. Once I read the code, I found that dmenu is tied to Mod4 (Windows Key) + P, then things started to work. One funny thing though was that firefox didn't show up. Looks like it doesn't play nice with firefox and so, I suspect it will not play nice with other GUI driven applications
  3. Bluetile - Super easy to get started with. Sadly, there is not much configuration that you can and so, its more like a demo for tiling rather. Plays nice with gnome as well. I wanted to install xmonad once I saw it but didn't want to download and install a bunch of stuff that I wouldn't use. If you are a haskeller, then go to xmonad directly, There's even a configuration available to make it look like bluetile.
  4. Awesome - I found this to be the best. Awesome is a fork of dwm with the explicit idea of configuration.Tons of layouts and plus it understands and implements several Freedesktop standards. So, it plays nice with gnome and you get menu integration as well. Only part I didn't like was the name because it makes googling difficult. Its the only one in the list for which the first hit on Google isn't the windowing manager. I also found that resizing didn't work. I'm not sure why but didn't spend time on it. Googling also showed up another person complaining about the same thing but no solution.
So,  I liked Awesome in the end. Its newbie friendly. The only real grouse is that you can't google for it easily. Bluetile is also very nice. DWM and StumpWM is more tuned for the power users. I really like the small size of dwm and the dynamic configuration of stumpwm but those points in themselves don't sell.

Once you use tiling for windows, there's no going back. One note of caution though. Other than Awesome and DWM, the others don't work with lightdm's menu without tweaking on Ubuntu 11.10. In all cases, you lose the panel (unless you install it yourself and its no longer part of GNOME 3).

Friday, December 16, 2011

Get a working ubuntu armel system from ubuntu core

This uses qemu-arm to set things up in 10 simple steps

1. Download the latest rootfs from http://cdimage.ubuntu.com/ubuntu-core/daily/current/
2. sudo untar it into a directory say arm-rootfs
3. cd arm-rootfs
4. cp /usr/bin/qemu-static-arm usr/bin. This will run for every command
5. cp /etc/resolv.conf etc/. This is so that we can get network access
6.  for m in `echo 'sys dev proc'`; do sudo mount /$m ./$m -o bind; done
5. Now sudo chroot . /bin/bash
6. apt-get update
7. Now run all the commands you need to finish downloading and installing software.
8 In the end unmount all the bound points  - for m in `echo 'sys dev proc'`; do sudo umount ./$m; done
9. Create the a tar ball
10. Publish!

Tips from  http://omappedia.org/wiki/OMAP_Ubuntu_Core