All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] doc: test-writing-guidelines
@ 2014-05-08  5:42 Xiaoguang Wang
  2014-05-13 13:39 ` chrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Xiaoguang Wang @ 2014-05-08  5:42 UTC (permalink / raw)
  To: ltp-list

Add 'verifying filesystem free space' paragraph.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 doc/test-writing-guidelines.txt | 50 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 91edbf0..0239b19 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -723,6 +723,56 @@ options passed to mkfs.
 The extra options 'fs_opts' should either be 'NULL' if there are none or a
 'NULL' terminated array of strings such as '{"-b", "1024", NULL}'.
 
+2.2.14 Verifying a filesystem's free space
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Some tests have size requirements for the filesystem's free space. If these
+requirements are not satisfied, some tests are not appropriate to run.
+Especially you run runltp with "-z" option to specify a big block device,
+different tests have different requirements for the free space of this
+block device, e.g. you specify a 500MB block device, testA needs 400MB free
+space and testB needs 600MB, then testA will surely fail. The tst_fs_has_free()
+below can be used to verify whether filesystem has enough free space, return 1
+if satisfied and 0 if not.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include "test.h"
+
+int tst_fs_has_free(void (*cleanup)(void), const char *path,
+		    unsigned int size, unsigned int mult);
+-------------------------------------------------------------------------------
+
+This function takes 4 arguments:
+    @path is the pathname of any file within filesystem you want to verify
+its free space.
+    @mult should be TST_BYTES, TST_KB, TST_MB or TST_GB.
+    the required free space is calculated by @size * @mult, e.g.
+tst_fs_has_free(cleanup, "/tmp/testfile", 64, TST_MB) will return 1 if the
+filesystem, which "/tmp/testfile" is in, has 64MB free space at least, and
+return 1 if not.
+
+There is also a similar shell interface:
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/bash
+
+...
+
+# whether current directory has 32KB free space at least.
+if ! tst_fs_has_free . 32; then
+	tst_brkm TCONF "Not enough free space"
+fi
+
+...
+-------------------------------------------------------------------------------
+
+The tst_fs_has_free shell interface return 0 if the specified free space
+is satisfied, 1 if not, and 2 for error. And the second argument support
+suffixes KB, MB and GB, so 32KB or 64MB is also valid. If not specifying
+a suffix, the default unit is 1 KB.
+
+
 2.3 Writing a testcase in shell
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.2.1


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH] doc: test-writing-guidelines
  2014-05-08  5:42 [LTP] [PATCH] doc: test-writing-guidelines Xiaoguang Wang
@ 2014-05-13 13:39 ` chrubis
  0 siblings, 0 replies; 8+ messages in thread
From: chrubis @ 2014-05-13 13:39 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: ltp-list

Hi!
> Add 'verifying filesystem free space' paragraph.
> 
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
>  doc/test-writing-guidelines.txt | 50 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)

I've reformatted the text a bit to be more readable, moved the shell
part to 'writing testcases in shell' section and fixed the default unit
for the shell tst_fs_has_free (that one changed to Bytes with my change
that introduced the suffixes).

Pushed to git and wiki, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH] doc: test-writing-guidelines
  2014-06-18  6:31 Xiaoguang Wang
@ 2014-06-18 11:37 ` chrubis
  0 siblings, 0 replies; 8+ messages in thread
From: chrubis @ 2014-06-18 11:37 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: ltp-list

Hi!
> Add paragraph to describe two new tst_ interfaces: tst_fs_fill_hardlinks() and
> tst_fs_fill_subdirs().
> 
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
>  doc/test-writing-guidelines.txt | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
> index 0a2ac8f..8513f46 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -773,6 +773,45 @@ The required free space is calculated by 'size * mult', e.g.
>  filesystem, which '"/tmp/testfile"' is in, has 64MB free space at least, and 0
>  if not.
>  
> +2.2.15 Getting maximal count of links to a regular file or directory
> +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I've fixed the formatting and pushed ltp git as well as wiki, thanks.

Note that the file is in asciidoc(1) format and your patch generated
syntax errors while generating the html version, because the whole
heading wasn't underlined with ^^^^ and because the lengt of ---- that
enclosed the code blocks did not match.

You can install asciidoc localy and check your changes just with
running:

asciidoc file-name.txt

which should produce file-name.html.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] doc: test-writing-guidelines
@ 2014-06-18  6:31 Xiaoguang Wang
  2014-06-18 11:37 ` chrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Xiaoguang Wang @ 2014-06-18  6:31 UTC (permalink / raw)
  To: ltp-list

Add paragraph to describe two new tst_ interfaces: tst_fs_fill_hardlinks() and
tst_fs_fill_subdirs().

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 doc/test-writing-guidelines.txt | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 0a2ac8f..8513f46 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -773,6 +773,45 @@ The required free space is calculated by 'size * mult', e.g.
 filesystem, which '"/tmp/testfile"' is in, has 64MB free space at least, and 0
 if not.
 
+2.2.15 Getting maximal count of links to a regular file or directory
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Some tests need to know the maximal count of links to a regular file or
+directory, such as rename(2) or linkat(2)'s EMLINK error value test.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include "test.h"
+
+int tst_fs_fill_hardlinks(void (*cleanup) (void), const char *dir);
+------------------------------------------------------------------------------
+
+Try to get maximal count of hard links to a regular file inside the @dir.
+Note: This number depends on the filesystem @dir is on. This function uses
+link(2) to create hard links to a single file until it gets EMLINK or creates
+65535 links. If limit is hit maximal number of hardlinks is returned and the
+@dir is filled with hardlinks in format "testfile%i" where i belongs to
+[0, limit) interval. If no limit is hit (succed to create 65535 without error)
+or if link() failed with ENOSPC or EDQUOT, zero is returned and previously
+created files are removed.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include "test.h"
+
+int tst_fs_fill_subdirs(void (*cleanup) (void), const char *dir);
+------------------------------------------------------------------------------
+
+Try to get maximum number of subdirectories in directory. Note: This number
+depends on the filesystem @dir is on. This function uses mkdir(2) to create
+directories in @dir until it gets EMLINK or creates 65535 directories.
+If limit is hit the maximal number of subdirectories is returned and the
+@dir is filled with subdirectories in format "testdir%i" where i belongs to
+[0, limit - 2) interval (because each newly created dir has two links
+allready the '.' and link from parent dir). If no limit is hit or mkdir()
+failed with ENOSPC or EDQUOT, zero is returned previously created directories
+are removed.
+
 2.3 Writing a testcase in shell
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.8.2.1


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH] doc: test-writing-guidelines
  2014-05-14  5:16 Xiaoguang Wang
@ 2014-05-14 11:46 ` chrubis
  0 siblings, 0 replies; 8+ messages in thread
From: chrubis @ 2014-05-14 11:46 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: ltp-list

Hi!
> Add paragraph to describe two new tst_ interfaces: tst_strsig and tst_strerrno.
> 
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>

Pushed to git and wiki, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] doc: test-writing-guidelines
@ 2014-05-14  5:16 Xiaoguang Wang
  2014-05-14 11:46 ` chrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Xiaoguang Wang @ 2014-05-14  5:16 UTC (permalink / raw)
  To: ltp-list

Add paragraph to describe two new tst_ interfaces: tst_strsig and tst_strerrno.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 doc/test-writing-guidelines.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index bf129a3..7cdaf2f 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -435,6 +435,21 @@ Exits the tests, note that this function has no parameters, the PASSES/FAILS
 reported by the 'tst_resm()' interfaces were stored and are used for the exit
 value.
 
+[source,c]
+-------------------------------------------------------------------------------
+const char *tst_strsig(int sig);
+-------------------------------------------------------------------------------
+
+Return the given signal number's corresponding string.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+const char *tst_strerrno(int err);
+-------------------------------------------------------------------------------
+
+Return the given errno number's corresponding string.
+
 
 2.2.3 Test temporary directory
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- 
1.8.2.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH] doc: test-writing-guidelines
  2014-03-27 13:28 Alexey Kodanev
@ 2014-03-27 13:52 ` chrubis
  0 siblings, 0 replies; 8+ messages in thread
From: chrubis @ 2014-03-27 13:52 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> Add thread-safety paragraph
> Add example of how to use TST_DECLARE_ONCE_FN

Pushed with minor changes:

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index a7250b7..9c3ea2a 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -675,12 +675,12 @@ bellow:
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 It is safe to use library 'tst_' functions in multi-threaded tests.
-Synchronization mechanism enabled only if the test is linked with pthread
+Synchronization mechanism is enabled only if the test is linked with pthread
 library, otherwise no-op stubs (defined in libc) are used.
 
-Also, LTP has a help "TST_DECLARE_ONCE_FN" macro to declare a function which
-must be run only once (e.g. init or cleanup function), but might be called
-by multiple threads in the same time. See example below:
+Also, LTP has a helper "TST_DECLARE_ONCE_FN" macro to declare a function which
+must be run only once (e.g. init or cleanup function), but might be called by
+multiple threads at the same time. See example below:


And also updated the online version in GitHub wiki. Thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] doc: test-writing-guidelines
@ 2014-03-27 13:28 Alexey Kodanev
  2014-03-27 13:52 ` chrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Alexey Kodanev @ 2014-03-27 13:28 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Add thread-safety paragraph
Add example of how to use TST_DECLARE_ONCE_FN

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 doc/test-writing-guidelines.txt |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 337a6a8..a7250b7 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -14,7 +14,7 @@ guide and it's not, by any means, a substitute for common sense.
 
 For all it's worth keep the testcases simple or better as simple as possible.
 The kernel and libc are tricky beasts and the complexity imposed by their
-interfaces is is quite high. Concentrate on the interface you want to test and
+interfaces is quite high. Concentrate on the interface you want to test and
 follow the UNIX philosophy. It's a good idea to make the test as
 self-contained as possible too (it should not depend on tools or libraries
 that are not widely available).
@@ -671,6 +671,40 @@ bellow:
 	}
 -------------------------------------------------------------------------------
 
+2.2.12 Thread-safety in the LTP library
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+It is safe to use library 'tst_' functions in multi-threaded tests.
+Synchronization mechanism enabled only if the test is linked with pthread
+library, otherwise no-op stubs (defined in libc) are used.
+
+Also, LTP has a help "TST_DECLARE_ONCE_FN" macro to declare a function which
+must be run only once (e.g. init or cleanup function), but might be called
+by multiple threads in the same time. See example below:
+
+[source,c]
+-------------------------------------------------------------------------------
+#include "test.h"
+
+...
+
+void do_cleanup(void)
+{
+	/* cleanup code */
+	...
+}
+TST_DECLARE_ONCE_FN(cleanup, do_cleanup);
+
+...
+
+void test01(void)
+{
+	sfd = socket(AF_INET, SOCK_STREAM, 0);
+	if (sfd == -1)
+		tst_brkm(TBROK, cleanup, "Failed to create a socket");
+}
+-------------------------------------------------------------------------------
+
 2.3 Writing a testcase in shell
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-18 11:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08  5:42 [LTP] [PATCH] doc: test-writing-guidelines Xiaoguang Wang
2014-05-13 13:39 ` chrubis
  -- strict thread matches above, loose matches on Subject: below --
2014-06-18  6:31 Xiaoguang Wang
2014-06-18 11:37 ` chrubis
2014-05-14  5:16 Xiaoguang Wang
2014-05-14 11:46 ` chrubis
2014-03-27 13:28 Alexey Kodanev
2014-03-27 13:52 ` chrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.