Revision: 2401
Author: pekka.klarck
Date: Sun Nov 29 16:36:55 2009
Log: reorg and some more text
http://code.google.com/p/robotframework/source/detail?r=2401
Modified:
/wiki/HowToUseC.wiki
=======================================
--- /wiki/HowToUseC.wiki Thu Nov 26 23:48:29 2009
+++ /wiki/HowToUseC.wiki Sun Nov 29 16:36:55 2009
@@ -5,21 +5,39 @@
= Introduction =
This simple example demonstrates how to use C language from Robot
-Framework test libraries. The example uses Python's standard
[http://docs.python.org/library/ctypes.html ctypes module], which requires
-that the C code is compiled into a shared library. This version is
-implemented and tested on Linux, but adapting it to other operating
-systems would require only changing compilation and name of the
-produced shared library.
-
-= Example =
-
-Please download the example:
[http://robotframework.googlecode.com/files/robotframework-c-example-20091023.zip
robotframework-c-example.zip].
-
-== System under test ==
-
-The demo application is simple login system that validates user name
-and password and prints out are they valid or not. There are two valid
-username password combinations: `demo/mode` and `john/long`.
+Framework test libraries. The example uses Python's standard
+[http://docs.python.org/library/ctypes.html ctypes module], which
+requires that the C code is compiled into a shared library. This
+version is implemented and tested on Linux, but adapting it to other
+operating systems would require only changing compilation and name of
+the produced shared library.
+
+
+= Getting and running the example =
+
+The example is available on the
+[http://code.google.com/p/robotframework/downloads/list download page]
+as
+[http://robotframework.googlecode.com/files/robotframework-c-example-20091023.zip
+robotframework-c-example-<date>.zip]. After downloading and unzipping
+the package, you should have all the files in a directory
+`robotframework-c-example`.
+
+To try out the example first run `make` in the directory that was
+created when you unzipped the package. This will create library
+`liblogin.so`, a shared library that is needed to use ctypes module.
+The example tests can be executed simply using the command below. All
+the test should pass.
+
+ `pybot LoginTests.tsv`
+
+
+= System under test =
+
+The demo application is a very simple login system, implemented using
+C, that validates the given user name and password and returns the
+status. There are two valid username password combinations:
+`demo/mode` and `john/long`.
{{{
#include <string.h>
@@ -43,11 +61,10 @@
}}}
-== Test library ==
-
-A simple test library that can execute the above program directly using
`ctypes`.
-It is also possible to execute this file from the command line
-to test the C code manually.
+= Test library =
+
+A simple test library that can interact with the above program using
+`ctypes` module. The library provides only one keyword `Check User`.
{{{
from ctypes import CDLL, c_char_p
@@ -73,7 +90,15 @@
print 'Valid password'
}}}
-== Test cases ==
+
+The `if __name__ == '__main__'` block above is not used by the
+executed tests, but it allows using the library code as a tool for
+manual testing. You can test this handy behavior by running, for
+example, `python LoginLibrary.py demo mode` or `python LoginLibrary.py
+demo invalid` on the command line.
+
+
+= Test cases =
|| `*** Settings ***` || || || ||
|| `Library` || `LoginLibrary.py` || || ||
@@ -96,16 +121,3 @@
|| `Check Invalid User` || `[Arguments]` || `${username}` || `${password}`
||
|| || `Run Keyword And Expect Error` || `Wrong username/password
combination` || `Check User` ||
|| || `...` || `${username}` || `${password}` ||
-
-= Building and running the example =
-
-To use the example run `make` in the directory where you unzipped the
-`robotframework-c-example.zip` package. This will create library
-`liblogin.so`, a shared library that is needed to use ctypes
-module. Run test by typing:
-
- `pybot LoginTests.tsv`
-
-You can also run the application as standalone using command:
-
- `python LoginLibrary.py demo mode`