PreferredTechnologies

Differences between revisions 15 and 16
Revision 15 as of 2012-04-16 08:20:39
Size: 3298
Editor: ev
Comment:
Revision 16 as of 2012-04-18 08:45:49
Size: 4599
Editor: host-2-98-203-10
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
== Overview == <<TableOfContents()>>

= Overview =
Line 5: Line 7:
== Testing ==
=== Python ===
= Testing and Debugging =
== Python ==
Line 16: Line 18:
=== C === == C ==
Line 19: Line 21:
   Basic memory checking:
 {{{#!highlight bash
   valgrind -v myprogram --arg=foo -baz
 }}}
   More aggressive checking:
 {{{#!highlight bash
valgrind -v \
  --track-fds=yes \
  --log-file=/tmp/valgrind.log \
  --tool=memcheck \
  --leak-check=full \
  --track-origins=yes \
  --malloc-fill=0x0 \
  --free-fill=0x0 \
  --show-reachable=yes \
  myprogram --arg=foo -baz
 }}}
   Deep magic which will spawn gdb when an error is detected (`--db-attach=yes`):
 {{{#!highlight bash
valgrind \
  -v \
  --trace-children=yes \
  --track-fds=yes \
  --time-stamp=yes \
  --db-attach=yes \
  --read-var-info=yes \
  --tool=memcheck \
  --leak-check=full \
  --leak-resolution=high \
  --num-callers=40 \
  --show-reachable=yes \
  --track-origins=yes \
  --undef-value-errors=yes \
  --freelist-vol=60000000 \
  --malloc-fill=0x7 \
  --free-fill=0x8 \
  myprogram --arg=foo -baz
 }}}
Line 23: Line 63:
    if type cppcheck >/dev/null 2>&1; then \     if type cppcheck -v >/dev/null 2>&1; then \
Line 27: Line 67:
 * splint
   Excellent static analysis tool. May now be unmaintained? Does not understand C99 (variadic macros).
 {{{#!highlight bash
   splint -I/usr/include -I/some/where -DMY_DEFINE=1 -DFOO src/main.c 2>&1|tee splint.log
 }}}
 * LLVM/Clang
 {{{#!highlight bash
   sudo apt-get install -y clang
   scan-build -v -v -v make 2>&1|tee scan-build.log
 }}}
Line 28: Line 78:
=== Performance testing === == Performance testing ==
Line 43: Line 93:
=== Cloud infrastructure === == Cloud infrastructure ==
Line 47: Line 97:
== Building == = Building =
Line 51: Line 101:
== Productivity == = Productivity =
Line 53: Line 103:
=== Efficiently splitting a terminal into several smaller windows === == Efficiently splitting a terminal into several smaller windows ==

Overview

This page represents our best attempt at gathering the common tools and practices used by engineers on the Ubuntu Foundations team.

Testing and Debugging

Python

Use pyflakes to check for common errors. Hook this up to your preferred test harness using something akin to the following:

Mock is one of the better mocking libraries and is already used in ubiquity, software-center, and apport.

C

  • valgrind
    • Basic memory checking:
       1    valgrind -v myprogram --arg=foo -baz
    
    • More aggressive checking:
       1 valgrind -v \
       2   --track-fds=yes \
       3   --log-file=/tmp/valgrind.log \
       4   --tool=memcheck \
       5   --leak-check=full \
       6   --track-origins=yes \
       7   --malloc-fill=0x0 \
       8   --free-fill=0x0 \
       9   --show-reachable=yes \
      10   myprogram --arg=foo -baz
    
    • Deep magic which will spawn gdb when an error is detected (--db-attach=yes):

       1 valgrind \
       2   -v \
       3   --trace-children=yes \
       4   --track-fds=yes \
       5   --time-stamp=yes \
       6   --db-attach=yes \
       7   --read-var-info=yes \
       8   --tool=memcheck \
       9   --leak-check=full \
      10   --leak-resolution=high \
      11   --num-callers=40 \
      12   --show-reachable=yes \
      13   --track-origins=yes \
      14   --undef-value-errors=yes \
      15   --freelist-vol=60000000 \
      16   --malloc-fill=0x7 \
      17   --free-fill=0x8 \
      18   myprogram --arg=foo -baz
    
  • cppcheck:
       1 check:
       2     ...
       3     if type cppcheck -v >/dev/null 2>&1; then \
       4         cppcheck . --error-exitcode=1; \
       5     fi
    
  • splint
    • Excellent static analysis tool. May now be unmaintained? Does not understand C99 (variadic macros).
       1    splint -I/usr/include -I/some/where -DMY_DEFINE=1 -DFOO src/main.c 2>&1|tee splint.log
    
  • LLVM/Clang
       1    sudo apt-get install -y clang
       2    scan-build -v -v -v make 2>&1|tee scan-build.log
    

Performance testing

  • judge runs two commands 50 times and provides the following report:

    ubuntu@server-8149:~$ ./judge/judge ./2281 ./with_changes
    v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
    
        n mean sd min max cmd
       50 10316.2ms 355.7 9945.9 11638.6 ./2281
       50 9867.5ms 625.8 9385.6 13061.3 ./with_changes
     -448.636ms -4.3% p=0.000
    difference is significant at 95.0% confidence (p=0.000):
    based on these samples, suggested sample size is n>=283 to have a 112.16ms confidence interval

Cloud infrastructure

cloud-init provides a means to run scripts during the creation of a Canonicloud instance. You can use this to create configurations for the infrastructure you need for a project and rapidly deploy that, either to develop or run tests against. See the code in whoopsie-daisy as an example.

Building

  • sbuild (far superior to pbuilder: quicker per-build setup, closer to Launchpad buildd environment, integrates well with schroot for ad-hoc testing)

Productivity

Efficiently splitting a terminal into several smaller windows

tmux is a terminal multiplexer, similar to GNU Screen, but arguably better.

Some tips:

  • The default keybindings let you use ^b arrow to move between panes. However, because this is a sequence of keys rather than a modifier, you can easily get into timing issues where you meant to move to the pane above, then downward in the open file, but actually moved to the pane above and back into the previous one. You can fix this by telling tmux to not wait for commands:

     set -g escape-time 0
  • You can bind a key to take the current tmux selection and put it in the X11 clipboard:
     unbind ^C
     bind ^C run "tmux show-buffer | xclip -i -selection clipboard"

    Using the standard keybindings, you would hit ^b^[ to enter copy mode, ^space to mark the beginning of a selection, the arrow keys to mark the end, and alt-w to select. Then press ^b^c to copy that text to the X11 clipboard.

FoundationsTeam/PreferredTechnologies (last edited 2024-10-16 11:12:07 by rkratky)