All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci
@ 2016-05-05 20:03 Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 1/5] pycocci: use os.path.abspath() for gitname Luis R. Rodriguez
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2016-05-05 20:03 UTC (permalink / raw)
  To: cocci

Coccinelle has its own test framework built-in to spatch, this
is used to test against small tests cases written in tests/*.c
with their respective tests/*.cocci and tests/*.res file. This
is however a bit limited as it only handles single C file. In
real world projects where more files are used we need to support
testing against larger series of file structures.

pycocci already had SmPL <=> Patch equivalence support, we can
leverage this to extend testing in a more generic fashion. This
does that work.

For now, we disable pycocci-tests given we touch your git tree
for these tests.

Luis R. Rodriguez (5):
  pycocci: use os.path.abspath() for gitname
  pycocci: add git branch support to git library
  pycocci: skip proof if git dir is dirty
  pycocci: add clean version of SmPL <=> Patch equivalence proof support
  pycocci: enable SmPL <=> Patch equivalence tests

 Makefile                                           |  3 +
 docs/pycocci.1                                     | 24 +++++-
 scripts/pycocci-check.sh                           |  8 ++
 tests/pycocci/code/0001-proto3/proto3.c            |  7 ++
 tests/pycocci/code/0001-proto3/proto3.h            |  3 +
 tests/pycocci/patches/0001-proto3.cocci            | 11 +++
 .../0001-proto3/0001-change-prototypes.patch       | 18 +++++
 tools/pycocci                                      | 89 ++++++++++++++++------
 8 files changed, 140 insertions(+), 23 deletions(-)
 create mode 100755 scripts/pycocci-check.sh
 create mode 100644 tests/pycocci/code/0001-proto3/proto3.c
 create mode 100644 tests/pycocci/code/0001-proto3/proto3.h
 create mode 100644 tests/pycocci/patches/0001-proto3.cocci
 create mode 100644 tests/pycocci/patches/0001-proto3/0001-change-prototypes.patch

-- 
2.7.2

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

* [Cocci] [PATCH 1/5] pycocci: use os.path.abspath() for gitname
  2016-05-05 20:03 [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Luis R. Rodriguez
@ 2016-05-05 20:03 ` Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 2/5] pycocci: add git branch support to git library Luis R. Rodriguez
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2016-05-05 20:03 UTC (permalink / raw)
  To: cocci

gitname() is currently used for SmPL <=> Patch
equivalence proof support. It uses git to test
for proofs and also show any differences found.
If the target directory passed where the user
wishes to do work on has is not part of a git
tree, it creates a git tree for you there.

When using relative paths the check for if a
target directory is part of a git tree currently
always fails, the consequences of which are that
if you try to show proof on an existing git tree
you'll end up with a sub-git project, and as such
a new .git under some directory under your target
path.

Correct this by using absolute paths.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 tools/pycocci | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/pycocci b/tools/pycocci
index 43bb9a4dd412..a7b0f69b25f0 100755
--- a/tools/pycocci
+++ b/tools/pycocci
@@ -246,9 +246,10 @@ def git_rev_parse(tree=None, extra_args=None):
     return stdout.split('\n', 1)[0]
 
 def gitname(path=None):
+    path = os.path.abspath(path)
     work_dir = path
     if not os.path.isdir(path):
-        work_dir = os.path.dirname(path)
+        work_dir = os.path.abspath(os.path.dirname(path))
     process = subprocess.Popen(['git', 'rev-parse', '--show-toplevel', path],
                                stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                                close_fds=True, universal_newlines=True, cwd=work_dir)
-- 
2.7.2

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

* [Cocci] [PATCH 2/5] pycocci: add git branch support to git library
  2016-05-05 20:03 [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 1/5] pycocci: use os.path.abspath() for gitname Luis R. Rodriguez
@ 2016-05-05 20:03 ` Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 3/5] pycocci: skip proof if git dir is dirty Luis R. Rodriguez
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2016-05-05 20:03 UTC (permalink / raw)
  To: cocci

This will be used later on an new command for pycocci.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 tools/pycocci | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/pycocci b/tools/pycocci
index a7b0f69b25f0..b53bcb778be2 100755
--- a/tools/pycocci
+++ b/tools/pycocci
@@ -276,6 +276,15 @@ def git_checkout(tree=None, extra_args=None):
     process.wait()
     _check(process)
 
+def git_branch(tree=None, extra_args=None):
+    cmd = ['git', 'branch' ] + extra_args
+    process = subprocess.Popen(cmd,
+                               stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+                               close_fds=True, universal_newlines=True, cwd=tree)
+    stdout = process.communicate()[0]
+    process.wait()
+    _check(process)
+
 def git_commit_all(message, tree=None):
     git_add('.', tree=tree)
     process = subprocess.Popen(['git', 'commit', '--allow-empty', '-a', '-m', message],
-- 
2.7.2

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

* [Cocci] [PATCH 3/5] pycocci: skip proof if git dir is dirty
  2016-05-05 20:03 [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 1/5] pycocci: use os.path.abspath() for gitname Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 2/5] pycocci: add git branch support to git library Luis R. Rodriguez
@ 2016-05-05 20:03 ` Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 4/5] pycocci: add clean version of SmPL <=> Patch equivalence proof support Luis R. Rodriguez
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2016-05-05 20:03 UTC (permalink / raw)
  To: cocci

SmPL <=> Patch equivalence proof support requires your
git tree to be clean, if it is dirty it will fail. To
avoid confusing users complain if their tree is dirty.

You will either need commit any local pending changes
or discard them before proceeding with SmPL <=> Patch
equivalence proof support.

Extend documentation for this.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 docs/pycocci.1 | 3 +++
 tools/pycocci  | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/docs/pycocci.1 b/docs/pycocci.1
index 63df731fdf46..e7f6b072589c 100644
--- a/docs/pycocci.1
+++ b/docs/pycocci.1
@@ -201,6 +201,9 @@ will set the tree back to the master branch. Each run of \fBpycocci --show-proof
 will create two new git branches. 8 random characters are postixed to each new
 git branch created to avoid conflicts with previous runs.
 
+You must run this option with a clean git tree, if you have any pending changes
+you must commit them or discard them.
+
 .SH AUTHOR
 \fBpycocci\fP and this man page was written by Luis R. Rodriguez <mcgrof@do-not-panic.com>
 
diff --git a/tools/pycocci b/tools/pycocci
index b53bcb778be2..4bcfb46af24b 100755
--- a/tools/pycocci
+++ b/tools/pycocci
@@ -575,6 +575,15 @@ def _main():
             logwrite("Path (%s) not part of a git tree, creating one for you...\n" % (args.target_dir))
             git_init(tree=args.target_dir)
             git_commit_all(tree=args.target_dir, message="Initial commit")
+        else:
+            diff_stat = git_diff(tree=args.target_dir, extra_args = [ '--stat' ] )
+            if len(diff_stat) != 0:
+                logwrite("SmPL <--> Patch proof equivalence requires a "
+                         "clean tree.\nYou have a dirty tree with "
+                         "uncommitted changes:\n\n")
+                logwrite(diff_stat)
+                logwrite("\nEither commit these changes, or stash them away somewhere\n")
+                return -2
         cmd = [ '--abbrev-ref', 'HEAD' ]
         current_branch = git_rev_parse(tree=args.target_dir, extra_args = cmd)
         logwrite("\n")
-- 
2.7.2

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

* [Cocci] [PATCH 4/5] pycocci: add clean version of SmPL <=> Patch equivalence proof support
  2016-05-05 20:03 [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Luis R. Rodriguez
                   ` (2 preceding siblings ...)
  2016-05-05 20:03 ` [Cocci] [PATCH 3/5] pycocci: skip proof if git dir is dirty Luis R. Rodriguez
@ 2016-05-05 20:03 ` Luis R. Rodriguez
  2016-05-05 20:03 ` [Cocci] [PATCH 5/5] pycocci: enable SmPL <=> Patch equivalence tests Luis R. Rodriguez
  2016-05-09  5:25 ` [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Julia Lawall
  5 siblings, 0 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2016-05-05 20:03 UTC (permalink / raw)
  To: cocci

When working with automated tests against proofs you expect mosts
tests to pass. Currently SmPL <=> Patch equivalence proof support
is too chatty for automated tests, and it also leaves in place the
two git branches it uses to test for proof. Add a new option for
pycocci which will be silent unless errors occur, and will also
remove the temporary git branches used for the proof unless an
error is found.

Extend documentation for this. Note that these tests use git
branches on your tree, pycocc-* branches are only left in your
tree if an error has occured. Even if successful, even if branches
are deleted there will be a period of time during which you will
still see these branches on your git reflog, by default this is
about 30 days. If you want to expedite clearing your reflog you
can use this after testing:

	git reflog expire --all --expire=now

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 docs/pycocci.1 | 21 +++++++++++++++++-
 tools/pycocci  | 68 ++++++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 67 insertions(+), 22 deletions(-)

diff --git a/docs/pycocci.1 b/docs/pycocci.1
index e7f6b072589c..2410022d641d 100644
--- a/docs/pycocci.1
+++ b/docs/pycocci.1
@@ -204,8 +204,27 @@ git branch created to avoid conflicts with previous runs.
 You must run this option with a clean git tree, if you have any pending changes
 you must commit them or discard them.
 
+.B\-c | \-\-clean\-proof
+This does what -\-show\-proof does but this is completely silent unless an
+error occurs. It will also remove the git branches used to test for the
+equivalence proof, unless an error is found. If an error is found you can
+inspect the two branches used to test for proof, refer to the documentation
+on \-\-show\-proof for details about these branches. This option is useful
+if you want to automate tests with proofs.
+
+Note that using this method will have created and subsequently if successful
+deleted two git branches on your git tree. As a consequence of using git
+branches your git reflog will show these branches, if you push your tree
+out these branches will not be pushed as they were deleted, your reflog
+however will keep these references locally until git expires them, by default
+this is 30 days. If this is too chatty for you, you can run:
+
+	git reflog expire \-\-all \-\-expire=now
+
+This will immediately clear old entries from your reflog.
+
 .SH AUTHOR
-\fBpycocci\fP and this man page was written by Luis R. Rodriguez <mcgrof@do-not-panic.com>
+\fBpycocci\fP and this man page was written by Luis R. Rodriguez <mcgrof@kernel.org>
 
 .SH REPORTING BUGS
 Send an mail to <cocci@systeme.lip6.fr>
diff --git a/tools/pycocci b/tools/pycocci
index 4bcfb46af24b..a667672ac2c5 100755
--- a/tools/pycocci
+++ b/tools/pycocci
@@ -346,7 +346,8 @@ def apply_patches(args, patch_src, target_dir, logwrite=lambda x:None):
     for pfile in patches:
         print_name = pfile[prefix_len:]
 
-        logwrite("Applying patch %s\n" % pfile)
+        if args.show_proof or args.verbose:
+            logwrite("Applying patch %s\n" % pfile)
 
         process = subprocess.Popen(['patch', '-p1'], stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT, stdin=subprocess.PIPE,
@@ -401,7 +402,8 @@ class ExecutionErrorCocci(CoccinelleError):
         logwrite("Failed to apply changes from %s\n" % print_name)
         logwrite(output)
 
-def spatch(cocci_file, outdir, logwrite, num_jobs, print_name, extra_args=[]):
+def spatch(cocci_file, outdir, logwrite, num_jobs, print_name, extra_args=[],
+           verbose=False):
 
     req = Req(chatty=True)
     req.coccinelle('1.0.2')
@@ -428,7 +430,8 @@ def spatch(cocci_file, outdir, logwrite, num_jobs, print_name, extra_args=[]):
 
     cmd.extend(extra_args)
 
-    logwrite("%s\n" % " ".join(cmd))
+    if verbose:
+        logwrite("%s\n" % " ".join(cmd))
 
     sprocess = subprocess.Popen(cmd,
                                 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
@@ -440,7 +443,8 @@ def spatch(cocci_file, outdir, logwrite, num_jobs, print_name, extra_args=[]):
     return output
 
 def spatch_old(cocci_file, outdir,
-               max_threads, thread_id, temp_dir, ret_q, extra_args=[]):
+               max_threads, thread_id, temp_dir, ret_q, extra_args=[],
+               verbose=False):
     cmd = ['spatch',
             '--sp-file', cocci_file,
             '--in-place',
@@ -456,7 +460,8 @@ def spatch_old(cocci_file, outdir,
 
     fn = os.path.join(temp_dir, '.tmp_spatch_worker.' + str(thread_id))
     outfile = open(fn, 'w')
-    logwrite("%s\n" % " ".join(cmd))
+    if verbose:
+        logwrite("%s\n" % " ".join(cmd))
 
     sprocess = subprocess.Popen(cmd,
                                stdout=outfile, stderr=subprocess.STDOUT,
@@ -466,7 +471,7 @@ def spatch_old(cocci_file, outdir,
     ret_q.put((sprocess.returncode, fn))
 
 def threaded_spatch(cocci_file, outdir, logwrite, num_jobs,
-                    print_name, extra_args=[]):
+                    print_name, extra_args=[], verbose=True):
     num_cpus = cpu_count()
     if num_jobs:
         threads = int(num_jobs)
@@ -515,6 +520,11 @@ def _main():
                         help='Enable profile, this will pass --profile  to Coccinelle.')
     parser.add_argument('-s', '--show-proof', const=True, default=False, action="store_const",
                         help='Show proof that the provided SmPL patch can replace a respective patch series')
+    parser.add_argument('-c', '--clean-proof', const=True, default=False, action="store_const",
+                        help='Show proof that the provided SmPL patch can replace a respective patch series, and' +
+                        'if the proof shows equivalence, delete any temporary branches used to test the proof.' +
+                        'If any errors were encountered the branches used to test the proof will be kept to ' +
+                        'enable debugging')
     parser.add_argument('-j', '--jobs', metavar='<jobs>', type=str, default=None,
                         help='Only use the cocci file passed for Coccinelle, don\'t do anything else, ' +
                         'also creates a git repo on the target directory for easy inspection ' +
@@ -553,9 +563,9 @@ def _main():
     git_dir = None
 
     if git_reqs.reqs_match():
-        git_dir = gitname(args.target_dir)
+        git_dir = gitname(path=args.target_dir)
 
-    if args.show_proof:
+    if args.show_proof or args.clean_proof:
         # As an example if you use --show-proof patches/collateral-evolutions/network/09-threaded-irq.cocci
         # the patches under 09-threaded-irq will be used for the proof.
         patch_src = args.cocci_file.split('/')[-1].split('.cocci')[0]
@@ -586,11 +596,12 @@ def _main():
                 return -2
         cmd = [ '--abbrev-ref', 'HEAD' ]
         current_branch = git_rev_parse(tree=args.target_dir, extra_args = cmd)
-        logwrite("\n")
-        logwrite("Current branch: %s\n" % (current_branch))
-        logwrite("Patch   branch: %s\n" % (patch_branch_name))
-        logwrite("SmPL    branch: %s\n" % (smpl_branch_name))
-        logwrite("\n")
+        if args.show_proof or args.verbose:
+            logwrite("\n")
+            logwrite("Current branch: %s\n" % (current_branch))
+            logwrite("Patch   branch: %s\n" % (patch_branch_name))
+            logwrite("SmPL    branch: %s\n" % (smpl_branch_name))
+            logwrite("\n")
         git_checkout(tree=args.target_dir, extra_args = ['-b', smpl_branch_name])
         git_checkout(tree=args.target_dir, extra_args = ['-b', patch_branch_name])
 
@@ -608,31 +619,46 @@ def _main():
     else:
         extra_spatch_args.append('--use-coccigrep')
 
+    show_spatch_cmd = True
+    if args.clean_proof and not args.verbose:
+        show_spatch_cmd = False
     if has_spatch_1_0_2.reqs_match():
         output = spatch(args.cocci_file, args.target_dir, logwrite, jobs,
                         os.path.basename(args.cocci_file),
-                        extra_args=extra_spatch_args)
+                        extra_args=extra_spatch_args, verbose=show_spatch_cmd)
     else:
         output = threaded_spatch(args.cocci_file,
                                  args.target_dir,
                                  logwrite,
                                  jobs,
                                  os.path.basename(args.cocci_file),
-                                 extra_args=extra_spatch_args)
+                                 extra_args=extra_spatch_args,
+                                 verbose=show_spatch_cmd)
     if args.verbose:
         logwrite(output)
-    if args.show_proof:
+    if args.show_proof or args.clean_proof:
         git_commit_all(tree=args.target_dir, message="Initial commit")
         git_checkout(tree=args.target_dir, extra_args = [current_branch])
         cmd = [ '--stat', patch_branch_name + ".." + smpl_branch_name ]
         diff_stat = git_diff(tree=args.target_dir, extra_args = cmd)
         if len(diff_stat) == 0:
-            logwrite('\nSmPL patch fully replaces patch series!\n')
+            if args.show_proof or args.verbose:
+                logwrite('\nSmPL patch fully replaces patch series!\n')
+            else:
+                logwrite('%s\t:OK\n' % args.cocci_file)
+            if args.clean_proof:
+                if args.verbose:
+                    logwrite('\nRequested clean proof, so deleting work branches\n')
+                git_branch(tree=args.target_dir, extra_args = ['-D', patch_branch_name])
+                git_branch(tree=args.target_dir, extra_args = ['-D', smpl_branch_name])
         else:
-            logwrite('\nDifferences found:\n\n')
-            logwrite('Change directory to %s and run:\n\n\tgit diff %s..%s\n\n' % (args.target_dir, patch_branch_name, smpl_branch_name))
-            logwrite('diffstat of the changes:\n')
-            logwrite(diff_stat)
+            if args.show_proof or args.verbose:
+                logwrite('\nDifferences found:\n\n')
+                logwrite('Change directory to %s and run:\n\n\tgit diff %s..%s\n\n' % (args.target_dir, patch_branch_name, smpl_branch_name))
+                logwrite('diffstat of the changes:\n')
+                logwrite(diff_stat)
+            else:
+                logwrite('%s\t:FAIL\n' % args.cocci_file)
     return 0
 
 if __name__ == '__main__':
-- 
2.7.2

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

* [Cocci] [PATCH 5/5] pycocci: enable SmPL <=> Patch equivalence tests
  2016-05-05 20:03 [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Luis R. Rodriguez
                   ` (3 preceding siblings ...)
  2016-05-05 20:03 ` [Cocci] [PATCH 4/5] pycocci: add clean version of SmPL <=> Patch equivalence proof support Luis R. Rodriguez
@ 2016-05-05 20:03 ` Luis R. Rodriguez
  2016-05-06 10:58   ` SF Markus Elfring
  2016-05-09  5:25 ` [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Julia Lawall
  5 siblings, 1 reply; 9+ messages in thread
From: Luis R. Rodriguez @ 2016-05-05 20:03 UTC (permalink / raw)
  To: cocci

Coccinelle has integrated tests support into it, these
tests are performed really fast, the current test framework
enables testing with respective single C file and a respective
cocci file, ie: foo.c, foo.cocci, foo.res. If one wants to add
extensive tests, to reflect more real-life sized projects the
current test scheme is a bit limited.

We can extend Coccinelle's existing test framework to support
multiple files, header files, but a different can also consist
of making use of SmPL <=> Patch equivalence support. Instead of
relying on .res files, this relies on patches that provide
a outline of differences using standard diff. This enables
extending test coverage to more complex cases. This is not
meant to replace Coccinelle's internal test functionality but
rather complement it.

For now, since I can't figure out how to only remove from
the reflog the temporary branch creation stuff without expiring
your entire relog immediately, just keep the pycocci-check
separate from the standard tests. If we're happy to have a
chatty reflog when testing we can later enable this by
default, but this just doesn't seem appropriate as a default
setting.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 Makefile                                               |  3 +++
 scripts/pycocci-check.sh                               |  8 ++++++++
 tests/pycocci/code/0001-proto3/proto3.c                |  7 +++++++
 tests/pycocci/code/0001-proto3/proto3.h                |  3 +++
 tests/pycocci/patches/0001-proto3.cocci                | 11 +++++++++++
 .../patches/0001-proto3/0001-change-prototypes.patch   | 18 ++++++++++++++++++
 6 files changed, 50 insertions(+)
 create mode 100755 scripts/pycocci-check.sh
 create mode 100644 tests/pycocci/code/0001-proto3/proto3.c
 create mode 100644 tests/pycocci/code/0001-proto3/proto3.h
 create mode 100644 tests/pycocci/patches/0001-proto3.cocci
 create mode 100644 tests/pycocci/patches/0001-proto3/0001-change-prototypes.patch

diff --git a/Makefile b/Makefile
index a98eefd2d83b..364e1cc68154 100644
--- a/Makefile
+++ b/Makefile
@@ -489,6 +489,9 @@ check: scripts/spatch
 	@$(ECHO) running the test suite
 	COCCINELLE_HOME="$$(pwd)" ./scripts/spatch --testall --no-update-score-file
 
+pycocci-check:
+	COCCINELLE_HOME="$$(pwd)" ./scripts/pycocci-check.sh
+
 # -inline 0  to see all the functions in the profile.
 # Can also use the profile framework in commons/ and run your program
 # with -profile.
diff --git a/scripts/pycocci-check.sh b/scripts/pycocci-check.sh
new file mode 100755
index 000000000000..ca81ca9cb156
--- /dev/null
+++ b/scripts/pycocci-check.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+set -e
+
+for i in tests/pycocci/patches/*.cocci; do
+	TEST=${i%%.cocci}
+	CODE_TEST=tests/pycocci/code/$(basename $TEST)
+	./tools/pycocci --clean-proof $i $CODE_TEST
+done
diff --git a/tests/pycocci/code/0001-proto3/proto3.c b/tests/pycocci/code/0001-proto3/proto3.c
new file mode 100644
index 000000000000..db3818afd5da
--- /dev/null
+++ b/tests/pycocci/code/0001-proto3/proto3.c
@@ -0,0 +1,7 @@
+#include "proto3.h"
+
+static void bch_sched_event(struct BCState *bcs, int event)
+{
+	bcs->event |= 1 << event;
+	schedule_work(&bcs->work);
+}
diff --git a/tests/pycocci/code/0001-proto3/proto3.h b/tests/pycocci/code/0001-proto3/proto3.h
new file mode 100644
index 000000000000..d4365e8c890e
--- /dev/null
+++ b/tests/pycocci/code/0001-proto3/proto3.h
@@ -0,0 +1,3 @@
+void bch_l2l1(struct PStack *st, int pr, void *arg);
+void bch_sched_event(struct BCState *bcs, int event);
+void bch_empty_fifo(struct BCState *bcs, int count);
diff --git a/tests/pycocci/patches/0001-proto3.cocci b/tests/pycocci/patches/0001-proto3.cocci
new file mode 100644
index 000000000000..d81678ef6d6e
--- /dev/null
+++ b/tests/pycocci/patches/0001-proto3.cocci
@@ -0,0 +1,11 @@
+@@
+identifier fn2;
+identifier bcs, ev;
+@@
+
+- fn2(struct BCState *bcs, int ev) {
++ fn2(int ev) {
+   ...
+   bcs->event |= 1 << ev;
+   schedule_work(&bcs->work);
+ }
diff --git a/tests/pycocci/patches/0001-proto3/0001-change-prototypes.patch b/tests/pycocci/patches/0001-proto3/0001-change-prototypes.patch
new file mode 100644
index 000000000000..e5b504e0acbb
--- /dev/null
+++ b/tests/pycocci/patches/0001-proto3/0001-change-prototypes.patch
@@ -0,0 +1,18 @@
+--- a/proto3.c
++++ b/proto3.c
+@@ -1,7 +1,6 @@
+ #include "proto3.h"
+ 
+-static void bch_sched_event(struct BCState *bcs, int event)
+-{
++static void bch_sched_event(int event) {
+ 	bcs->event |= 1 << event;
+ 	schedule_work(&bcs->work);
+ }
+--- a/proto3.h
++++ b/proto3.h
+@@ -1,3 +1,3 @@
+ void bch_l2l1(struct PStack *st, int pr, void *arg);
+-void bch_sched_event(struct BCState *bcs, int event);
++void bch_sched_event(int event);
+ void bch_empty_fifo(struct BCState *bcs, int count);
-- 
2.7.2

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

* [Cocci] [PATCH 5/5] pycocci: enable SmPL <=> Patch equivalence tests
  2016-05-05 20:03 ` [Cocci] [PATCH 5/5] pycocci: enable SmPL <=> Patch equivalence tests Luis R. Rodriguez
@ 2016-05-06 10:58   ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2016-05-06 10:58 UTC (permalink / raw)
  To: cocci

> We can extend Coccinelle's existing test framework to support
> multiple files, header files, but a different can also consist
> of making use of SmPL <=> Patch equivalence support. Instead of
> relying on .res files, this relies on patches that provide
> a outline of differences using standard diff.

Does this wording need a bit more fine-tuning to make
the understanding easier for the suggested software development?

Regards,
Markus

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

* [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci
  2016-05-05 20:03 [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Luis R. Rodriguez
                   ` (4 preceding siblings ...)
  2016-05-05 20:03 ` [Cocci] [PATCH 5/5] pycocci: enable SmPL <=> Patch equivalence tests Luis R. Rodriguez
@ 2016-05-09  5:25 ` Julia Lawall
  2016-05-09 16:45   ` Luis R. Rodriguez
  5 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2016-05-09  5:25 UTC (permalink / raw)
  To: cocci

Acked-by: Julia Lawall <julia.lawall@lip6.fr>

for all of the patches in this series.

julia

On Thu, 5 May 2016, Luis R. Rodriguez wrote:

> Coccinelle has its own test framework built-in to spatch, this
> is used to test against small tests cases written in tests/*.c
> with their respective tests/*.cocci and tests/*.res file. This
> is however a bit limited as it only handles single C file. In
> real world projects where more files are used we need to support
> testing against larger series of file structures.
> 
> pycocci already had SmPL <=> Patch equivalence support, we can
> leverage this to extend testing in a more generic fashion. This
> does that work.
> 
> For now, we disable pycocci-tests given we touch your git tree
> for these tests.
> 
> Luis R. Rodriguez (5):
>   pycocci: use os.path.abspath() for gitname
>   pycocci: add git branch support to git library
>   pycocci: skip proof if git dir is dirty
>   pycocci: add clean version of SmPL <=> Patch equivalence proof support
>   pycocci: enable SmPL <=> Patch equivalence tests
> 
>  Makefile                                           |  3 +
>  docs/pycocci.1                                     | 24 +++++-
>  scripts/pycocci-check.sh                           |  8 ++
>  tests/pycocci/code/0001-proto3/proto3.c            |  7 ++
>  tests/pycocci/code/0001-proto3/proto3.h            |  3 +
>  tests/pycocci/patches/0001-proto3.cocci            | 11 +++
>  .../0001-proto3/0001-change-prototypes.patch       | 18 +++++
>  tools/pycocci                                      | 89 ++++++++++++++++------
>  8 files changed, 140 insertions(+), 23 deletions(-)
>  create mode 100755 scripts/pycocci-check.sh
>  create mode 100644 tests/pycocci/code/0001-proto3/proto3.c
>  create mode 100644 tests/pycocci/code/0001-proto3/proto3.h
>  create mode 100644 tests/pycocci/patches/0001-proto3.cocci
>  create mode 100644 tests/pycocci/patches/0001-proto3/0001-change-prototypes.patch
> 
> -- 
> 2.7.2
> 
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

* [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci
  2016-05-09  5:25 ` [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Julia Lawall
@ 2016-05-09 16:45   ` Luis R. Rodriguez
  0 siblings, 0 replies; 9+ messages in thread
From: Luis R. Rodriguez @ 2016-05-09 16:45 UTC (permalink / raw)
  To: cocci

On Mon, May 09, 2016 at 07:25:55AM +0200, Julia Lawall wrote:
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> 
> for all of the patches in this series.

Thanks, applied and pushed.

  Luis

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

end of thread, other threads:[~2016-05-09 16:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-05 20:03 [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Luis R. Rodriguez
2016-05-05 20:03 ` [Cocci] [PATCH 1/5] pycocci: use os.path.abspath() for gitname Luis R. Rodriguez
2016-05-05 20:03 ` [Cocci] [PATCH 2/5] pycocci: add git branch support to git library Luis R. Rodriguez
2016-05-05 20:03 ` [Cocci] [PATCH 3/5] pycocci: skip proof if git dir is dirty Luis R. Rodriguez
2016-05-05 20:03 ` [Cocci] [PATCH 4/5] pycocci: add clean version of SmPL <=> Patch equivalence proof support Luis R. Rodriguez
2016-05-05 20:03 ` [Cocci] [PATCH 5/5] pycocci: enable SmPL <=> Patch equivalence tests Luis R. Rodriguez
2016-05-06 10:58   ` SF Markus Elfring
2016-05-09  5:25 ` [Cocci] [PATCH 0/5] coccinelle: extend testing with check-pycocci Julia Lawall
2016-05-09 16:45   ` Luis R. Rodriguez

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.