├── .gitignore
├── .gitlab-ci.yml
├── .gitmodules
├── .lisp-format
├── .qlfile.external
├── .qlfile.grammatech
├── GrammaTech-CLA-resolve.pdf
├── LICENSE.txt
├── Makefile
├── README.md
├── alg.md
├── alist.lisp
├── ast-diff.lisp
├── auto-merge.lisp
├── bin
├── .gitignore
├── git-ast-diff
└── rest-ast-diff
├── build.lisp
├── build
├── .gitignore
├── LICENSE.txt
├── README.md
└── resolve.asd
├── commands.lisp
├── core.lisp
├── css
└── ast-diff.css
├── doc
├── .gitignore
├── changelog.texi
├── pub
│ ├── merge-resolver-tech-approach.tex
│ ├── merge.bib
│ └── related-work.org
└── resolve.texi
├── exp
├── .gitignore
├── README.md
├── TODO.org
├── auto-merge-js-notes.md
├── auto-merge-js
│ ├── ccl-seed
│ ├── get-merge-commit.sh
│ ├── sbcl-seed
│ ├── test.sh
│ └── try-all-js-auto-merges
├── bin
│ ├── all-merges
│ ├── conflicting-merges
│ ├── get-merge-data
│ ├── merge-diff3
│ ├── try-all-cdbs
│ ├── try-all-cdbs-in-image-loop.sh
│ ├── try-all-merges
│ ├── try-merge
│ ├── try-stats
│ └── try-tss
├── conflicts
│ ├── tss
│ ├── tss-all
│ └── tss-crashing
├── lisp
│ └── try-all-merges.lisp
├── pub
│ ├── .gitignore
│ ├── Makefile
│ ├── acknowledgments.tex
│ ├── conclusion.tex
│ ├── experiments.tex
│ ├── intro.tex
│ ├── main.tex
│ ├── methodology.tex
│ ├── refs.bib
│ └── related.tex
├── results.org
└── results
│ ├── cc-diff3.txt
│ ├── cc-merges.txt
│ ├── cc-stats.txt
│ ├── js-merges.txt
│ └── js-stats.txt
├── html.lisp
├── js
└── ast-diff.js
├── resolve.asd
├── resolve.org
├── routes
├── diff.lisp
└── merge.lisp
├── software
├── auto-mergeable.lisp
├── lisp.lisp
├── parseable.lisp
└── project.lisp
├── string.lisp
├── test.lisp
└── test
├── ad-hoc.lisp
├── bin
├── ast-diff-on-json-has-lines
├── ast-diff-on-lisp-has-lines
├── ast-diff-on-simple-has-lines
├── ast-merge-json-has-conflict
├── can-auto-merge-gcd-project
├── can-auto-merge-gcd-project-delete-file-evolve
├── can-auto-merge-gcd-project-evolve
├── can-auto-merge-gcd-project-insert-file-evolve
├── can-auto-merge-gcd-single-file
├── can-auto-merge-gcd-single-file-evolve
├── can-auto-merge-text-project
├── can-auto-merge-text-project-delete-file-evolve
├── can-auto-merge-text-project-evolve
├── can-auto-merge-text-project-insert-file-evolve
├── can-auto-merge-text-single-file
├── can-auto-merge-text-single-file-evolve
├── clang-diff-on-gcd
├── clang-diff-on-gcd-edit-tree
├── clang-diff-on-gcd-edit-tree-coherence
├── common
├── javascript-diff-on-gcd
├── lisp-diff-on-gcd
├── lisp-diff-on-gcd-raw
├── lisp-diff-w-wrap-on-gcd
├── octomap-diff
├── octomap-diff-count
├── octomap-diff-edit-tree
├── rest-ast-diff-can-return-and-serve-link
├── rest-ast-diff-returns-json
└── rest-ast-diff-takes-full-strings
└── etc
├── binary_search.c
├── gcd-project-auto-merge
├── gcd-1
│ ├── Makefile
│ ├── gcd.c
│ ├── gcd.h
│ └── main.c
├── gcd-2
│ ├── Makefile
│ ├── gcd.c
│ ├── gcd.h
│ └── main.c
├── gcd-3
│ ├── Makefile
│ ├── gcd.c
│ ├── gcd.h
│ └── main.c
└── test.sh
├── gcd-project-delete-file-auto-merge
├── gcd-1
│ ├── Makefile
│ └── main.c
├── gcd-2
│ ├── Makefile
│ ├── gcd.c
│ ├── gcd.h
│ └── main.c
├── gcd-3
│ ├── Makefile
│ └── main.c
└── test.sh
├── gcd-project-insert-file-auto-merge
├── gcd-1
│ ├── Makefile
│ ├── gcd1.c
│ ├── gcd1.h
│ └── main.c
├── gcd-2
│ ├── Makefile
│ ├── gcd.c
│ ├── gcd.h
│ └── main.c
├── gcd-3
│ ├── Makefile
│ ├── gcd.c
│ ├── gcd.h
│ └── main.c
└── test.sh
├── gcd-single-file-auto-merge
├── gcd-1.c
├── gcd-2.c
├── gcd-3.c
└── test.sh
├── gcd
├── .gitignore
├── gcd-fix.js
├── gcd-fix.lisp
├── gcd-prose.js
├── gcd-wo-curlies-fix.c
├── gcd-wo-curlies-prose.c
├── gcd-wo-curlies.c
├── gcd.c
├── gcd.js
├── gcd.lisp
├── gcd.s.att
├── gcd.s.intel
├── gcd.traces
├── gcd2.c
├── limit.c
├── repair-asm.lisp
├── repair-ast.lisp
├── repair-gcd.lisp
├── repair-lisp.lisp
├── repair.lisp
├── simple
│ └── gcd.c
├── test-lisp.sh
└── test.sh
├── javascript
├── abacus
│ ├── .gitignore
│ ├── abacus-animate.js
│ ├── abacus-bead.js
│ ├── abacus-borders.js
│ ├── abacus-calc-line.js
│ ├── abacus-even.js
│ ├── abacus-min-lines.js
│ ├── abacus-orig.js
│ ├── abacus-space.js
│ └── test.sh
├── atom
│ ├── package-after.js
│ └── package-before.js
├── fib-project
│ ├── app.js
│ ├── fib.js
│ ├── package.json
│ └── test.sh
├── fib
│ ├── fib.js
│ └── test.sh
├── hello-world
│ └── hello-world.js
├── package-json
│ ├── base-d5da5eb.json
│ ├── left-ea14630.json
│ └── right-6655688.json
├── parsing
│ ├── array-destructuring.js
│ ├── arrow-function-expression.js
│ ├── await-expression.js
│ ├── class-declaration.js
│ ├── class-expression.js
│ ├── conditional-expression.js
│ ├── debugger-statement.js
│ ├── empty-statement.js
│ ├── export-specifier.js
│ ├── expression-statement.js
│ ├── function-declaration.js
│ ├── function-expression.js
│ ├── if.js
│ ├── import-specifier.js
│ ├── labeled-statement.js
│ ├── loops.js
│ ├── new-expression.js
│ ├── object-destructuring.js
│ ├── object-expression.js
│ ├── property.js
│ ├── sequence-expression.js
│ ├── spread-element.js
│ ├── switch.js
│ ├── tagged-template-expression.js
│ ├── try-catch-throw.js
│ ├── with-statement.js
│ └── yield-expression.js
└── trivial.json
├── octomap
├── octomap-1.7.2
│ ├── include
│ │ └── octomap
│ │ │ ├── #OcTree.h#
│ │ │ ├── AbstractOcTree.h
│ │ │ ├── AbstractOccupancyOcTree.h
│ │ │ ├── ColorOcTree.h
│ │ │ ├── CountingOcTree.h
│ │ │ ├── MCTables.h
│ │ │ ├── MapCollection.h
│ │ │ ├── MapCollection.hxx
│ │ │ ├── MapNode.h
│ │ │ ├── MapNode.hxx
│ │ │ ├── OcTree.h
│ │ │ ├── OcTreeBase.h
│ │ │ ├── OcTreeBaseImpl.h
│ │ │ ├── OcTreeBaseImpl.hxx
│ │ │ ├── OcTreeBaseSE.h
│ │ │ ├── OcTreeBaseSE.hxx
│ │ │ ├── OcTreeDataNode.h
│ │ │ ├── OcTreeDataNode.hxx
│ │ │ ├── OcTreeIterator.hxx
│ │ │ ├── OcTreeKey.h
│ │ │ ├── OcTreeLUT.h
│ │ │ ├── OcTreeLUTdefs.h
│ │ │ ├── OcTreeNode.h
│ │ │ ├── OcTreeStamped.h
│ │ │ ├── OccupancyOcTreeBase.h
│ │ │ ├── OccupancyOcTreeBase.hxx
│ │ │ ├── Pointcloud.h
│ │ │ ├── ScanGraph.h
│ │ │ ├── math
│ │ │ ├── Pose6D.h
│ │ │ ├── Quaternion.h
│ │ │ ├── Utils.h
│ │ │ └── Vector3.h
│ │ │ ├── octomap.h
│ │ │ ├── octomap_deprecated.h
│ │ │ ├── octomap_timing.h
│ │ │ ├── octomap_types.h
│ │ │ └── octomap_utils.h
│ └── src
│ │ ├── test_iterators.cpp
│ │ └── testing.h
└── octomap-1.8.0
│ ├── include
│ └── octomap
│ │ ├── AbstractOcTree.h
│ │ ├── AbstractOccupancyOcTree.h
│ │ ├── ColorOcTree.h
│ │ ├── CountingOcTree.h
│ │ ├── MCTables.h
│ │ ├── MapCollection.h
│ │ ├── MapCollection.hxx
│ │ ├── MapNode.h
│ │ ├── MapNode.hxx
│ │ ├── OcTree.h
│ │ ├── OcTreeBase.h
│ │ ├── OcTreeBaseImpl.h
│ │ ├── OcTreeBaseImpl.hxx
│ │ ├── OcTreeDataNode.h
│ │ ├── OcTreeDataNode.hxx
│ │ ├── OcTreeIterator.hxx
│ │ ├── OcTreeKey.h
│ │ ├── OcTreeNode.h
│ │ ├── OcTreeStamped.h
│ │ ├── OccupancyOcTreeBase.h
│ │ ├── OccupancyOcTreeBase.hxx
│ │ ├── Pointcloud.h
│ │ ├── ScanGraph.h
│ │ ├── math
│ │ ├── Pose6D.h
│ │ ├── Quaternion.h
│ │ ├── Utils.h
│ │ └── Vector3.h
│ │ ├── octomap.h
│ │ ├── octomap_deprecated.h
│ │ ├── octomap_timing.h
│ │ ├── octomap_types.h
│ │ └── octomap_utils.h
│ └── src
│ ├── test_iterators.cpp
│ └── testing.h
├── read_words.h
├── sed-compile
├── Makefile
├── basicdefs.h
├── compile-after.c
├── compile-before.c
├── config.h
├── sed.h
├── unlocked-io.h
└── utils.h
├── simple
├── seq-10-edit.txt
├── seq-10.txt
├── simple-loop-after.c
└── simple-loop-before.c
├── text-project-auto-merge
├── test.sh
├── text1
│ ├── a
│ ├── b
│ └── package.json
├── text2
│ ├── a
│ ├── b
│ └── package.json
└── text3
│ ├── a
│ ├── b
│ └── package.json
├── text-project-delete-file-auto-merge
├── test.sh
├── text1
│ ├── a
│ └── package.json
├── text2
│ ├── a
│ ├── b
│ └── package.json
└── text3
│ ├── a
│ └── package.json
├── text-project-insert-file-auto-merge
├── test.sh
├── text1
│ ├── b
│ ├── c
│ └── package.json
├── text2
│ ├── a
│ ├── b
│ └── package.json
└── text3
│ ├── a
│ ├── b
│ └── package.json
└── text-single-file-auto-merge
├── test.sh
├── text1
├── text2
└── text3
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled files
2 | *.fas
3 | *.fasl
4 | *.lx64fsl
5 |
6 | system-index.txt
7 | .qlfile
8 | wiki/
9 |
10 | README.html
11 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | GIT_SUBMODULE_STRATEGY: recursive
3 |
4 | default:
5 | image: $DOCKER_REGISTRY/$CI_PROJECT_NAMESPACE/sel
6 | tags: ["kubernetes", "cluster"]
7 | before_script:
8 | - cp -r $(pwd)/ /root/quicklisp/local-projects/
9 | - cd /root/quicklisp/local-projects/$CI_PROJECT_NAME
10 | - GT=yes make dependencies
11 |
12 | check-format:
13 | stage: .pre
14 | script:
15 | - git lisp-format
16 |
17 | build-manual:
18 | stage: test
19 | script:
20 | - GT=yes make doc
21 |
22 | .test-template: &test
23 | stage: test
24 | script:
25 | - LISP=$LISP GT=yes make long-unit-check bin-check
26 |
27 | test-sbcl:
28 | variables:
29 | LISP: 'sbcl'
30 | <<: *test
31 |
32 | test-ccl:
33 | variables:
34 | LISP: 'ccl'
35 | <<: *test
36 |
37 | binary-release:
38 | stage: build
39 | artifacts:
40 | paths:
41 | - $CI_PROJECT_NAME
42 | script:
43 | - sbcl --script build.lisp
44 | - ccl --load build.lisp --eval '(quit)'
45 | - mv build $CI_PROJECT_DIR/$CI_PROJECT_NAME
46 | only:
47 | - master
48 |
49 | binary-release-deploy:
50 | stage: deploy
51 | needs: ['binary-release', 'test-ccl', 'test-sbcl']
52 | before_script:
53 | - mkdir -p ~/.ssh
54 | - ssh-keyscan -H download-updater.grammatech.com >> ~/.ssh/known_hosts
55 | script:
56 | - tar czf $CI_PROJECT_NAME.tar.gz $CI_PROJECT_NAME/*
57 | - tar --list -f $CI_PROJECT_NAME.tar.gz
58 | - sshpass -p $MNEMO_ARTIFACTS_PASSWORD scp -p $CI_PROJECT_NAME.tar.gz mnemosyne@download-updater.grammatech.com:.
59 | - 'curl https://download-updater.grammatech.com/mnemosyne/sync-request/ | grep -E "RESPONSE: ACCEPTED|BUSY"'
60 | only:
61 | - master
62 |
63 |
64 | dependent-bug-injector:
65 | stage: deploy
66 | only: [master]
67 | except: [schedules]
68 | trigger: synthesis/bug-injector
69 |
70 | dependent-mergeresolver:
71 | stage: deploy
72 | only: [master]
73 | except: [schedules]
74 | trigger: synthesis/resolve-app
75 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule ".cl-make"]
2 | path = .cl-make
3 | url = https://github.com/GrammaTech/cl-make.git
4 | branch = master
5 |
--------------------------------------------------------------------------------
/.lisp-format:
--------------------------------------------------------------------------------
1 | ;;;; -*- emacs-lisp -*-
2 | (mapc (lambda (dir) (add-to-list 'load-path dir))
3 | (directory-files (concat (getenv "QUICK_LISP")
4 | "/dists/quicklisp/software/") t "slime-v*"))
5 | (defun verbose-require (package)
6 | (unless (ignore-errors (require package))
7 | (message "Failed to load the package '%S'." package)
8 | (message "Ensure %s is installed locally, and then edit your" package)
9 | (message "\"~/.lisp-formatrc\" file adding %s to your load path.\n" package)
10 | (message " (add-to-list 'load-path )\n" package)
11 | ;; After printing the messages require again to trigger the error.
12 | (require package)))
13 | (verbose-require 'slime)
14 | (verbose-require 'paredit)
15 |
16 | (set-default 'indent-tabs-mode nil)
17 | (pushnew 'untabify *lisp-format-fixers*)
18 |
19 | (defun fix-trailing-parens (start end &optional _arg)
20 | "Use `paredit-close-parenthesis' to fix trailing parens."
21 | (interactive (if current-prefix-arg
22 | (list (point-min) (point-max) current-prefix-arg)
23 | (list (region-beginning) (region-end) nil)))
24 | (let ((c (current-column)))
25 | (save-excursion
26 | (save-restriction
27 | (narrow-to-region (point-min) end)
28 | (goto-char start)
29 | (while (re-search-forward "^ *)" nil t)
30 | (forward-char -1)
31 | (paredit-close-parenthesis))))
32 | (move-to-column c)))
33 | (pushnew 'fix-trailing-parens *lisp-format-fixers*)
34 |
35 | ;;; Syntax table extension for curry-compose-reader-macros
36 | (modify-syntax-entry ?\[ "(]" lisp-mode-syntax-table)
37 | (modify-syntax-entry ?\] ")[" lisp-mode-syntax-table)
38 | (modify-syntax-entry ?\{ "(}" lisp-mode-syntax-table)
39 | (modify-syntax-entry ?\} "){" lisp-mode-syntax-table)
40 | (modify-syntax-entry ?\« "(»" lisp-mode-syntax-table)
41 | (modify-syntax-entry ?\» ")«" lisp-mode-syntax-table)
42 |
43 | ;;; Specify indentation levels for specific functions.
44 | (mapc (lambda (pair) (put (first pair) 'lisp-indent-function (second pair)))
45 | '((make-instance 1)
46 | (if-let 1)
47 | (if-let* 1)
48 | (when-let 1)
49 | (when-let* 1)
50 | (defroute 2)
51 | (defixture 1)))
52 |
53 | (defun define-feature-lisp-indent
54 | (path state indent-point sexp-column normal-indent)
55 | "Indentation function called by `lisp-indent-function' for define-feature."
56 | ;; (message "CALLED: %S"
57 | ;; (list 'define-feature-lisp-indent
58 | ;; path state indent-point sexp-column normal-indent))
59 | (cond
60 | ((equalp path '(2)) 2) ; Doc string for enclosing define-feature.
61 | ((equalp path '(3)) 2) ; Extractor function definition.
62 | ((equalp path '(3 2)) 4) ; Doc string for extractor.
63 | ((equalp path '(4)) 2) ; Merge function definition.
64 | (t nil))) ; Otherwise do the default.
65 | (put 'define-feature 'lisp-indent-function 'define-feature-lisp-indent)
66 |
--------------------------------------------------------------------------------
/.qlfile.external:
--------------------------------------------------------------------------------
1 | git command-line-arguments https://github.com/fare/command-line-arguments.git
2 | git gt https://github.com/GrammaTech/cl-utils.git
3 | git functional-trees https://github.com/GrammaTech/functional-trees.git
4 | git sel http://git.grammatech.com/synthesis/sel.git
5 | git stefil+ https://github.com/GrammaTech/stefil-.git main
6 | git cffi https://github.com/death/cffi
7 | git cl-tree-sitter https://github.com/death/cl-tree-sitter
8 |
--------------------------------------------------------------------------------
/.qlfile.grammatech:
--------------------------------------------------------------------------------
1 | git command-line-arguments https://github.com/fare/command-line-arguments.git
2 | git gt http://git.grammatech.com/synthesis/gt.git
3 | git functional-trees http://git.grammatech.com/synthesis/functional-trees.git
4 | git sel http://git.grammatech.com/synthesis/sel.git
5 | git testbot http://git.grammatech.com/synthesis/testbot.git
6 | git stefil+ https://github.com/GrammaTech/stefil-.git main
7 | git cffi https://github.com/death/cffi
8 | git cl-tree-sitter https://github.com/death/cl-tree-sitter
9 |
--------------------------------------------------------------------------------
/GrammaTech-CLA-resolve.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GrammaTech/resolve/bf5f32c12005e09fa3099c2de1f386e40ae0f88a/GrammaTech-CLA-resolve.pdf
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: doc api
2 |
3 | # Set personal or machine-local flags in a file named local.mk
4 | ifneq ("$(wildcard local.mk)","")
5 | include local.mk
6 | endif
7 |
8 | PACKAGE_NAME = resolve
9 | DOC_PACKAGES = \
10 | resolve/alist \
11 | resolve/ast-diff \
12 | resolve/commands \
13 | resolve/html \
14 | resolve/string \
15 | resolve/ast-diff
16 |
17 | LISP_DEPS = \
18 | $(wildcard *.lisp) \
19 | $(wildcard software/*.lisp)
20 |
21 | BINS = ast-diff ast-merge auto-merge serve-ast-diff serve-auto-merge
22 |
23 | BIN_TEST_DIR = test/bin
24 | # BIN_TESTS = \
25 | # can-auto-merge-gcd-single-file \
26 | # can-auto-merge-gcd-single-file-evolve \
27 | # can-auto-merge-gcd-project \
28 | # can-auto-merge-gcd-project-evolve \
29 | # can-auto-merge-gcd-project-insert-file-evolve \
30 | # can-auto-merge-gcd-project-delete-file-evolve \
31 | # can-auto-merge-text-single-file \
32 | # can-auto-merge-text-single-file-evolve \
33 | # can-auto-merge-text-project \
34 | # can-auto-merge-text-project-evolve \
35 | # can-auto-merge-text-project-insert-file-evolve \
36 | # can-auto-merge-text-project-delete-file-evolve
37 | # ast-diff-on-lisp-has-lines \
38 | # ast-diff-on-simple-has-lines \
39 | # lisp-diff-on-gcd \
40 | # lisp-diff-on-gcd-raw \
41 | # clang-diff-on-gcd
42 | # FIXME:
43 | #
44 | # Convert to tree-sitter:
45 | # clang-diff-on-gcd-edit-tree # error
46 | # clang-diff-on-gcd-edit-tree-coherence # error
47 | # octomap-diff
48 | # octomap-diff-count # not sure
49 | # octomap-diff-edit-tree # not sure
50 | #
51 | # Old failures:
52 | # ast-diff-on-json-has-lines
53 | # javascript-diff-on-gcd
54 | # ast-merge-json-has-conflict
55 |
56 | # REST tests are only executed for SBCL builds.
57 | # CCL reports an error on rest server startup related to the use of
58 | # "#$O_NONBLOCK" in the cl-plus-ssl library at
59 | # https://github.com/cl-plus-ssl/cl-plus-ssl/blame/master/src/streams.lisp#L180.
60 | # This issue may be related to an incorrect installation of CCL; see also
61 | # https://lists.clozure.com/pipermail/openmcl-devel/2011-January/008283.html.
62 | # For now, we are punting and disabling these tests on CCL builds.
63 | # ifneq (,$(findstring sbcl, $(LISP)))
64 | # BIN_TESTS += \
65 | # rest-ast-diff-returns-json \
66 | # rest-ast-diff-can-return-and-serve-link
67 | # # FIXME
68 | # # rest-ast-diff-takes-full-strings \
69 |
70 | # endif
71 |
72 | include .cl-make/cl.mk
73 |
--------------------------------------------------------------------------------
/bin/.gitignore:
--------------------------------------------------------------------------------
1 | ast-diff
2 | ast-merge
3 | auto-merge
4 | serve-ast-diff
5 | serve-auto-merge
6 |
--------------------------------------------------------------------------------
/bin/git-ast-diff:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # A wrapper script for ast-diff to allow its invocation as a git
4 | # external diff tool. Git will pass 7 arguments to this tool,
5 | #
6 | # base-name old-file old-hex old-mode new-file new-hex new-mode
7 | #
8 | # where as ast-diff only wants the second and fifth arguments.
9 | #
10 | # To configure git to use ast-diff run the following in a repository:
11 | #
12 | # git config diff.external /full/path/to/resolve/bin/git-ast-diff
13 | #
14 | # or run the following to configure its use globally.
15 | #
16 | # git config --global diff.external /full/path/to/resolve/bin/git-ast-diff
17 | #
18 | # If you have configured this script as your git-diff driver, and you
19 | # run into problems, you can disable it for individual runs by passing
20 | # the --no-ext-diff option to git-diff.
21 | #
22 | # NOTE: Define the environment variable GIT_AST_DIFF_DEBUG to a file
23 | # name to collect debug output into that file. Unset that variable to
24 | # avoid collecting debug output. If you do this you will collect MANY
25 | # temporary files in your /tmp/ directory.
26 | bold=$(tput bold)
27 | normal=$(tput sgr0)
28 |
29 | declare -a OPTIONS
30 |
31 | # Collect all options to pass to ast-diff.
32 | while [ $# -gt 6 ];do
33 | case $1 in
34 | -*) OPTIONS+=($1); OPTIONS+=($2); shift; shift;;
35 | *) break;;
36 | esac
37 | done
38 |
39 | echo "${bold}ast-diff $1"
40 | if [ "$5" == "/dev/null" ];then
41 | echo "${bold}deleted file mode $4"
42 | diff --color=always "$2" "$5"
43 | exit 0
44 | elif [ "$2" == "/dev/null" ];then
45 | echo "${bold}created file mode $7"
46 | diff --color=always "$2" "$5"
47 | exit 0
48 | else
49 | echo "${bold}index $(echo $3|cut -c -8)..$(echo $6|cut -c -8) $7"
50 | fi
51 |
52 | ## With debugging.
53 | if [ ! -z ${GIT_AST_DIFF_DEBUG} ];then
54 | echo -e "ast-diff ${OPTIONS[@]}\n$@" >> "${GIT_AST_DIFF_DEBUG}"
55 | SUFFIX=".$(echo $1|sed 's/.*\.//;s|^/||;s|[^/]*/||')"
56 | BASE="$(basename $1 "${SUFFIX}")"
57 | backup(){ cp $1 $(mktemp -t --suffix="${SUFFIX}" "${BASE}-$2-XXXX"); }
58 | backup $2 "OLD"
59 | backup $5 "NEW"
60 | PROFILE=$(mktemp -t "${BASE}-prof-XXXX" --suffix=".data")
61 | ast-diff ${OPTIONS[@]} --verbose 4 --eval "(setf *profile-flame-graph* t)" --profile "${PROFILE}" "$2" "$5"
62 | EXIT=$?
63 | echo -e "Returned $EXIT\n" >> ${GIT_AST_DIFF_DEBUG}
64 | else
65 | ## Without debugging.
66 | ast-diff ${OPTIONS[@]} "$2" "$5"
67 | EXIT=$?
68 | fi
69 | if [ $EXIT == 1 ] || [ $EXIT == 0 ];then
70 | exit 0
71 | else
72 | exit $EXIT
73 | fi
74 |
--------------------------------------------------------------------------------
/bin/rest-ast-diff:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Usage: rest-ast-diff [OPTIONS] old-file new-file
4 | # Run AST-DIFF through the REST interface.
5 | #
6 | # OPTIONS:
7 | # -h,--help ---------- show this help text
8 | # -H,--host HOST ----- host to contact (default: localhost)
9 | # -p,--port PORT ----- port to contact (default: 5000)
10 | # -a,--accept MIME --- mime type accepted (default: application/json)
11 | # -l,--language LANG - set the language (default: none)
12 | # -L,--link ---------- request a link back
13 | #
14 | # NOTE: If we find that at some point we want to release this utility,
15 | # we should probably rewrite it as a simple C executable which
16 | # is statically linked with CURL and JQ avoiding unnecessary
17 | # dependencies on the user's system. Should be straightforward.
18 | SCRIPT="$0"
19 | help(){
20 | local HELP_TEXT=$(cat "$SCRIPT" \
21 | |sed '/^[^#]/q' \
22 | |head -n -1 \
23 | |tail -n +3 \
24 | |sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' \
25 | |cut -c3-)
26 | echo "$HELP_TEXT"
27 | exit 1
28 | }
29 |
30 | HOST=localhost
31 | PORT=5000
32 | ACCEPT=application/json
33 | LANGUAGE=
34 | LINK=
35 |
36 | eval set -- $(getopt -o hH:p:a:l:L -l help,host:,port:,accept:,language:,link -- "$@" || help;)
37 | while [ $# -gt 0 ];do
38 | case $1 in
39 | -h|--help) help;;
40 | -H|--host) HOST=$2; shift;;
41 | -p|--port) PORT=$2; shift;;
42 | -a|--accept) ACCEPT=$2; shift;;
43 | -l|--language) LANGUAGE=", \"language\" : \"$2\""; shift;;
44 | -L|--link) LINK=", \"link\" : \"YES\"";;
45 | (--) shift; break;;
46 | (-*) error "unrecognized option $1";;
47 | (*) break;;
48 | esac
49 | shift
50 | done
51 | if [ -z $1 ] || [ -z $2 ];then
52 | help
53 | fi
54 | OLD_FILE=$1
55 | NEW_FILE=$2
56 |
57 | PAYLOAD="$(jq -n \
58 | --arg OLD "$(cat $OLD_FILE)" \
59 | --arg NEW "$(cat $NEW_FILE)" \
60 | "{\"old-file\": \$OLD, \"new-file\": \$NEW ${LANGUAGE} ${LINK}}")"
61 |
62 | curl -X POST \
63 | -H "Accept: application/json" \
64 | -H "Content-Type: ${ACCEPT}" \
65 | http://${HOST}:${PORT}/diff \
66 | --data "${PAYLOAD}"
67 |
--------------------------------------------------------------------------------
/build.lisp:
--------------------------------------------------------------------------------
1 | (load "~/quicklisp/setup.lisp")
2 | (ql:quickload '(:gt
3 | :diff
4 | :cl-strftime
5 | :jsown
6 | :cl-interpol
7 | :cl-json
8 | :babel
9 | :software-evolution-library
10 | :resolve))
11 |
12 | (asdf:initialize-output-translations
13 | (list :output-translations :ignore-inherited-configuration
14 | (list (merge-pathnames "**/*.*" #+ccl (ccl::current-directory))
15 | (merge-pathnames "build/**/*.*" #+ccl (ccl::current-directory)))))
16 | (asdf:initialize-source-registry
17 | (list :source-registry :ignore-inherited-configuration
18 | (list :directory (merge-pathnames "src/" #+ccl (ccl::current-directory)))
19 | (list :tree (merge-pathnames "quicklisp/dists/" #+ccl (ccl::current-directory)))))
20 | (asdf:operate :deliver-asd-op :resolve/ast-diff)
21 |
--------------------------------------------------------------------------------
/build/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 | !resolve.asd
4 | !LICENSE.txt
5 | !README.md
6 |
--------------------------------------------------------------------------------
/build/README.md:
--------------------------------------------------------------------------------
1 | ## Copyright and License
2 | Copyright (c) 2020 GrammaTech, Inc. All rights reserved.
3 |
4 | Resolve, and any accompanying documentation or other materials are
5 | GrammaTech, Inc. (GrammaTech) Proprietary Information.
6 |
7 | Resolve is published under the GNU AFFERO GENERAL PUBLIC LICENSE, see
8 | [LICENSE.txt](LICENSE.txt) for more information.
9 |
10 | ## Acknowledgment
11 | This material is based upon work supported by the Defense Advanced
12 | Research Projects Agency (DARPA) under Contract No. D17PC00096. Any
13 | opinions, findings and conclusions or recommendations expressed in
14 | this material are those of the author(s) and do not necessarily
15 | reflect the views of the Defense Advanced Research Projects Agency
16 | (DARPA); or its Contracting Agent, the U.S. Department of the
17 | Interior, Interior Business Center, Acquisition Services Directorate,
18 | Division III.
19 |
--------------------------------------------------------------------------------
/core.lisp:
--------------------------------------------------------------------------------
1 | ;;;; core.lisp -- Core software search replace implementation.
2 | (defpackage :resolve/core
3 | (:use :gt/full
4 | :software-evolution-library/utility/git)
5 | (:import-from :fare-quasiquote)
6 | (:export :+resolve-dir+
7 | :+resolve-version+
8 | :+resolve-branch+
9 | :define-pattern-matching-weakening-mutation
10 | :resolve-readtable))
11 | (in-package :resolve/core)
12 | (in-readtable :curry-compose-reader-macros)
13 |
14 |
15 | ;;;; RESOLVE Constants.
16 | (defvar +resolve-dir+
17 | (pathname-directory
18 | #.(or *compile-file-truename*
19 | *load-truename*
20 | *default-pathname-defaults*))
21 | "Path to directory holding RESOLVE.")
22 |
23 | (defvar +resolve-version+
24 | (eval-when (:compile-toplevel :load-toplevel :execute)
25 | (current-git-commit +resolve-dir+))
26 | "Current version of the RESOLVE library.")
27 |
28 | (defvar +resolve-branch+
29 | (eval-when (:compile-toplevel :load-toplevel :execute)
30 | (current-git-branch +resolve-dir+))
31 | "Current branch of the RESOLVE library.")
32 |
33 | (defreadtable resolve-readtable
34 | (:fuse
35 | :standard
36 | :curry-compose-reader-macros
37 | :fare-quasiquote))
38 |
--------------------------------------------------------------------------------
/css/ast-diff.css:
--------------------------------------------------------------------------------
1 | body {}
2 | span.same {}
3 | span.delete{ background:pink;}
4 | span.insert{ background:lightgreen;}
5 |
--------------------------------------------------------------------------------
/doc/.gitignore:
--------------------------------------------------------------------------------
1 | include/
2 | resolve/
3 |
4 | # Documentation cruft
5 | *.1.gz
6 | *.aux
7 | *.bak
8 | *.bbl
9 | *.blg
10 | *.bll
11 | *.docx
12 | *.fdb_latexmk
13 | *.fls
14 | *.glg
15 | *.glo
16 | *.gls
17 | *.glsdefs
18 | *.info
19 | *.lof
20 | *.log
21 | *.lot
22 | *.md.tmp
23 | *.nav
24 | *.out
25 | *.pdf
26 | *.pgf
27 | *.snm
28 | *.svg
29 | *.tmp
30 | *.toc
31 | *.vrb
32 | *.xdy
33 |
34 | # Automatically generated package texi files
35 | resolve-alist-api.texi
36 | resolve-ast-diff-api.texi
37 | resolve-commands-api.texi
38 | resolve-html-api.texi
39 | resolve-string-api.texi
40 |
--------------------------------------------------------------------------------
/doc/changelog.texi:
--------------------------------------------------------------------------------
1 | @c https://keepachangelog.com/en/0.3.0/
2 | @c
3 | @c Any change in the version number should merit an entry in this
4 | @c changelog. Especially minor version or greater or anything that
5 | @c fixes a bug or a security issue. Any breaking changes ABSOLUTELY
6 | @c must be mentioned in this changelog.
7 | @c
8 | @c Format for each entry is as follows.
9 | @c
10 | @c @subsection YYYY-MM-DD v.X.X.X -- Textual Description
11 | @c @cindex changelog-YYYY-MM-DD
12 | @c @cindex v.X.X.X
13 | @c
14 | @c List of breaking or important changes. Every breaking change
15 | @c should be accompanied by an example of how to change existing
16 | @c code in response to the change.
17 | @c
18 | @c Changelog entries with multiple changes should grouped them by:
19 | @c - Added
20 | @c - Changed
21 | @c - Deprecated
22 | @c - Removed
23 | @c - Fixed
24 | @c - Security
25 | @c
26 |
27 | Resolve will use @url{https://semver.org/,semantic versioning} to
28 | determine increments to version numbers. This ChangeLog will be
29 | roughly organized as described at
30 | @url{https://keepachangelog.com/en/0.3.0/,Keep a ChangeLog}. Most
31 | importantly every version will include at least one ChangeLog entry,
32 | and the entries will be sorted in reverse chronological order with the
33 | most recent at the top. Every entry will be named and indexed by date
34 | and version number. Working notes may be accumulated in a special
35 | ``Unreleased'' section at the top of the ChangeLog.
36 |
37 | @appendixsec 2019-04-24 v0.0.0 -- Unreleased
38 | @cindex changelog-2019-04-24
39 | @cindex v0.0.0
40 |
41 | Initial version.
42 |
--------------------------------------------------------------------------------
/doc/pub/merge-resolver-tech-approach.tex:
--------------------------------------------------------------------------------
1 | \mr works in two phases. First it leverages GrammaTech's
2 | \gls{ast}-based software differencing (\autoref{ast-diff}) to find
3 | semantically meaningful differences between two versions of software
4 | against a shared base version, and to try to merge these differences
5 | resulting in a merged piece of software with possible areas of
6 | conflict. Second \mr iterative steps through the identified chunks
7 | attempting to resolve them using standard resolution schemes
8 | identified in large-scale empirical reviews of software merging by
9 | real developers. The final resolution is presented to users in the
10 | standard GitHub user interface (\autoref{github-api}).
11 |
12 | More detail on the \mr technique is available through the web-page for
13 | the GitHub application we built for
14 | \mr.\footnote{\url{https://mergeresolver.github.io/}}
15 |
16 | \begin{figure}
17 | \begin{center}
18 | \adjustbox{max width=\textwidth}{\includegraphics{figures/Screen_Shot_2020-06-11_at_10.png}}
19 | \end{center}
20 | \caption[AST-based software differencing]{\label{ast-diff}Results of
21 | the application of \gls{ast}-based software differencing to a
22 | real-world merge conflict form the popular JQuery JavaScript
23 | repository.}
24 | \end{figure}
25 |
26 | \begin{figure}
27 | \begin{center}
28 | \adjustbox{max width=\textwidth}{\includegraphics{figures/screenshot-3.png}}
29 | \end{center}
30 | \caption[\mr GitHub API]{\label{github-api}\mr GitHub API in which developers can
31 | accept a merge resolution.}
32 | \end{figure}
33 |
--------------------------------------------------------------------------------
/doc/pub/merge.bib:
--------------------------------------------------------------------------------
1 | @article{nugroho2020different,
2 | author={Nugroho, Yusuf Sulistyo and Hata, Hideaki and Matsumoto, Kenichi},
3 | title={How different are different diff algorithms in Git?},
4 | journal={Empirical Software Engineering},
5 | year={2020},
6 | volume={25},
7 | number={1},
8 | pages={790--823}
9 | }
10 |
11 | @article{horwitz1989integrating,
12 | author={Horwitz, Susan and Prins, Jan and Reps, Thomas},
13 | title={Integrating noninterfering versions of programs},
14 | journal={ACM Transactions on Programming Languages and Systems (TOPLAS)},
15 | year={1989},
16 | volume={11},
17 | number={3},
18 | pages={345--387}
19 | }
20 |
--------------------------------------------------------------------------------
/doc/resolve.texi:
--------------------------------------------------------------------------------
1 | \input texinfo
2 |
3 | @documentencoding utf-8
4 | @settitle Resolve
5 |
6 | @copying
7 | This file documents Resolve
8 |
9 | Copyright (C) 2019 GrammaTech
10 | @end copying
11 |
12 | @dircategory Utilities
13 | @direntry
14 | * Resolve: (resolve). Software difference display and resolution
15 | @end direntry
16 |
17 | @titlepage
18 | @title Resolve
19 | @page
20 | @vskip 0pt plus 1filll
21 | @insertcopying
22 | @end titlepage
23 |
24 | @c Output the table of the contents at the beginning.
25 | @contents
26 |
27 |
28 |
29 | @ifnottex
30 | @node Top, Introduction, (dir), (dir)
31 | @top Resolve
32 |
33 | @insertcopying
34 | @end ifnottex
35 |
36 |
37 | Resolve is a library and a number of tools for software difference
38 | display and conflict resolution.
39 |
40 | @menu
41 | * Introduction:: What is Resolve?
42 | * Tools:: Tools provided by Resolve.
43 | * Usage:: Using Resolve, including examples.
44 |
45 | Appendices
46 | * ChangeLog:: Chronological log of notable changes by version
47 | * Index:: Complete index.
48 |
49 | @end menu
50 |
51 |
52 | @node Introduction, Tools, Top, Top
53 | @chapter Introduction
54 | @cindex introduction
55 |
56 |
57 | @node Tools, AST Differencing, Introduction, Top
58 | @chapter Tools
59 | @cindex tools
60 |
61 | @menu
62 | * AST Differencing:: Calculate differences between ASTs
63 | @end menu
64 |
65 | @node AST Differencing, Usage, Tools, Tools
66 | @section AST Differencing
67 | @cindex ast-differencing
68 | @include include/ast-diff.texi
69 |
70 | @node Usage, ChangeLog, Tools, Top
71 | @chapter Usage
72 | @cindex usage
73 |
74 | @menu
75 | * Options:: Options to resolve tools
76 | * Examples:: Example usage of resolve tools
77 | @end menu
78 |
79 | @node Options, edit-tree, Usage, Usage
80 | @section Options
81 | @cindex options
82 |
83 | @menu
84 | * edit-tree:: TODO: brief description
85 | @end menu
86 |
87 | @node edit-tree, Examples, Options, Options
88 | @subsection edit-tree
89 | @cindex edit-tree
90 |
91 | TODO: long form description of the edit-tree option.
92 |
93 | @node Examples, ChangeLog, Options, Usage
94 | @section Examples
95 | @cindex examples
96 |
97 | TODO: examples of using ast-diff and ast-merge.
98 |
99 | @node ChangeLog, Index, Usage, Top
100 | @appendix ChangeLog
101 | @include changelog.texi
102 |
103 |
104 | @node Index, , ChangeLog, Top
105 | @unnumbered Index
106 |
107 | @c Combine all index (function variable type and concept) types into a
108 | @c single index.
109 | @syncodeindex fn cp
110 | @syncodeindex vr cp
111 | @syncodeindex tp cp
112 | @printindex cp
113 |
114 | @bye
115 |
--------------------------------------------------------------------------------
/exp/.gitignore:
--------------------------------------------------------------------------------
1 | js-repos/
2 | cc-repos/
3 | *.stdout
4 | *.stderr
5 | *.tar.xz
6 |
--------------------------------------------------------------------------------
/exp/README.md:
--------------------------------------------------------------------------------
1 | Merge Conflict Empirical Investigation and Experimentation
2 | ==========================================================
3 |
4 | For methodology and results see [results.org](results.org).
5 |
6 | For notes and tasks see [TODO.org](TODO.org).
7 |
--------------------------------------------------------------------------------
/exp/TODO.org:
--------------------------------------------------------------------------------
1 | #+Title: Merge Experiment Notes and Tasks
2 | #+Options: ^:{}
3 |
4 | * Notes
5 | ** Language coverage
6 | We could run on JavaScript and Common Lisp (and possibly Java)
7 | currently.
8 |
9 | Lets look at running on JS for now.
10 |
11 | * Tasks [0/4]
12 | ** TODO We should run on JavaScript programs as well [/]
13 | - [ ] Ping Jason for info
14 | - [ ] Collect and find conflicts in JS programs
15 |
16 | Grabbing the whole first page of the most depended upon NPM packages.
17 | Every single one has it's source code hosted on GitHub. All but two
18 | had their own github repository. Those two were:
19 | - https://www.npmjs.com/package/babel-core
20 | - https://www.npmjs.com/package/babel-runtime
21 | which are each sub-directories of the same repository.
22 |
23 | ** TODO Ping Shin Wei and Sergey to see if they're on board
24 | ** STARTED Collect CDBs for every version of every project [0/2]
25 | - [ ] Should these be using older versions of dependencies for older
26 | commits. Do we want to do something like checkout the contemporary
27 | version of every dependency?
28 | - [ ] Address all of those with 100% failure. Something is certainly
29 | wrong there.
30 |
--------------------------------------------------------------------------------
/exp/auto-merge-js/ccl-seed:
--------------------------------------------------------------------------------
1 | #.(CCL::INITIALIZE-MRG31K3P-STATE 1270880143 176389872 314159 498615371 352341342 271828)
--------------------------------------------------------------------------------
/exp/auto-merge-js/get-merge-commit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Output the merge commit in PROJECT corresponding to the
4 | # given git hashes representing the branches involved
5 | # in the merge.
6 | #
7 | # $1 - JavaScript project directory
8 | # $2 - Commit hash for the left branch of the merge
9 | # $3 - Commit hash for the right branch of the merge
10 |
11 | PROJECT=$1
12 | LEFT=$2
13 | RIGHT=$3
14 |
15 | pushd $1 > /dev/null
16 | for commit in $(git log --pretty="format:%h");
17 | do
18 | git show $commit | egrep -q "^Merge: $LEFT $RIGHT"
19 | if [ $? -eq 0 ]; then
20 | RESOLUTION=$commit
21 | break
22 | fi
23 | done
24 | popd > /dev/null
25 |
26 | if [ ! -z $RESOLUTION ]; then
27 | echo $RESOLUTION
28 | exit 0
29 | else
30 | exit 1
31 | fi
32 |
--------------------------------------------------------------------------------
/exp/auto-merge-js/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test harness for auto-merge JavaScript experiments.
4 | #
5 | # Run the test suite for the project given as the first argument.
6 | # For those conflicted merges which touch the test directory,
7 | # copy the test files from the resolved merge.
8 | #
9 | # $1 - JavaScript project directory
10 | # $2 - Commit hash for the resolution of the merge
11 |
12 | # Enter the project directory.
13 | cd $1
14 |
15 | # Store the resolution commit hash.
16 | RESOLUTION=$2
17 |
18 | # Determine if a test file has been modified.
19 | # If so, checkout the file from the merge resolution.
20 | for file in $(git diff --name-only $RESOLUTION);
21 | do
22 | echo $file | grep -q -E "^test/|^tests/|^__tests__/"
23 | if [ $? -eq 0 ]; then
24 | git checkout $RESOLUTION -- $file
25 | fi
26 | done
27 |
28 | # Run the tests
29 | timeout --signal 9 300 npm install && \
30 | timeout --signal 9 300 npm test
31 |
--------------------------------------------------------------------------------
/exp/bin/all-merges:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Print every merge commit for a repository.
4 | #
5 | TMPFILE=/tmp/merges$$
6 |
7 | if [ $1"" = "" ]; then
8 | OUT=$TMPFILE
9 | else
10 | OUT=$1
11 | fi;
12 | cat /dev/null > $OUT
13 | for d in `git log --pretty="format:%h"`; do
14 | x=`git show $d | egrep "^Merge"`
15 | if [ $? = "0" ]; then
16 | # Merge
17 | y=`echo $x | sed -e "s/^Merge: //"`
18 | echo $y >> $OUT
19 | echo $y | sed -e "s/\$/ ==> $d/"
20 | # else
21 | # no merge
22 | fi;
23 | # | sed -e "s/\$/ ==> $d/" | sed -e "s/Merge: //";
24 | done
25 |
--------------------------------------------------------------------------------
/exp/bin/conflicting-merges:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Usage: conflicting-merges REPOS...
4 | # Find the merges in REPOS(s) that cause conflicts.
5 | #
6 | # OPTIONS:
7 | # -h,--help ---------- print this help information
8 | #
9 | SCRIPT="$0"
10 | help(){
11 | local HELP_TEXT=$(cat "$SCRIPT" \
12 | |sed '/^[^#]/q' \
13 | |head -n -1 \
14 | |tail -n +3 \
15 | |sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' \
16 | |cut -c3-)
17 | echo "$HELP_TEXT"
18 | exit 1
19 | }
20 |
21 | eval set -- $(getopt -o h -l help -- "$@" || help;)
22 | while [ $# -gt 0 ];do
23 | case $1 in
24 | -h|--help) help;;
25 | (--) shift; break;;
26 | (-*) error "unrecognized option $1";;
27 | (*) break;;
28 | esac
29 | shift
30 | done
31 | if [ -z $1 ];then
32 | help
33 | fi
34 |
35 | function testconflict() {
36 | foo=$1
37 | bar=$2
38 | mergebase=$(git merge-base $foo $bar)
39 | if [ "$mergebase" = "" ];then
40 | # In case foo and bar have no common ancestor,
41 | # use the empty tree as the merge base
42 | mergebase=4b825dc642cb6eb9a060e54bf8d69288fbee4904
43 | fi
44 | #test if the output has conflict markers of "merge" style
45 | git merge-tree $mergebase $foo $bar | xargs 2>/dev/null |
46 | if grep -qoe '<<<<<<<.*=======.*>>>>>>>'; then
47 | echo -e "${NAME}\tconflict\t$mergebase\t$foo\t$bar"
48 | else
49 | echo -e "${NAME}\tno-conflict\t$mergebase\t$foo\t$bar"
50 | fi
51 | }
52 |
53 | for REPO in $@;do
54 | pushd ${REPO} 2>/dev/null >/dev/null
55 | NAME=$(basename ${REPO} .git)
56 | for d in $(git log --pretty="format:%h"); do
57 | m=$(git show $d | grep "^Merge");
58 | if [ "$m" != "" ]; then
59 | parts=(${m});
60 | testconflict ${parts[1]} ${parts[2]};
61 | fi
62 | done
63 | popd 2>/dev/null >/dev/null
64 | done
65 |
--------------------------------------------------------------------------------
/exp/bin/get-merge-data:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Collect merge/conflict data on the repo in which this
4 | # script is run. Outputs two lines: number of merges found
5 | # in the repo, and the number of merges that caused conflicts
6 |
7 | # This is inefficient, and we're going to want to see the merges
8 | # themselves anyway. TODO: generate tables of merges (and conflicting
9 | # merges) separately.
10 |
11 | all-merges | wc -l
12 | conflicting-merges | grep "^conflict" | wc -l
13 |
--------------------------------------------------------------------------------
/exp/bin/merge-diff3:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # usage: merge-diff3 base-id branch-id1 branch-id2
4 | #
5 | # Computes a diff3 of the (conflict) merge from base-id to branch-id1 and
6 | # branch-id2. The three versions are placed in tmp directories.
7 | BASE=$(pwd)
8 |
9 | TMP1=/tmp/md3-$1/
10 | TMP2=/tmp/md3-$2/
11 | TMP3=/tmp/md3-$3/
12 | rm -rf $TMP1 $TMP2 $TMP3
13 | mkdir $TMP1 $TMP2 $TMP3
14 |
15 | # https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset
16 | for HASH in $1 $2 $3;do
17 | TMP=/tmp/md3-$HASH/
18 | rm -rf $TMP
19 | git clone $BASE $TMP
20 | pushd $TMP
21 | git reset --hard $HASH
22 | popd
23 | done 2>/dev/null >/dev/null
24 |
25 | for f in `git diff --name-only $2 $3 --`; do
26 | echo
27 | echo $f:
28 | diff3 -A $TMP2/$f $TMP1/$f $TMP3/$f
29 | done
30 |
--------------------------------------------------------------------------------
/exp/bin/try-all-cdbs:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Usage: try-all-cdbs [OPTION]... REPOSITORY...
4 | # Try to build every CDB in every REPOSITORY
5 | #
6 | # OPTIONS:
7 | # -h,--help ---------- print this help information
8 | # -o,--outdir DIR ---- Save results to outdir
9 | # defaults to the current directory
10 | # -d, --docker DOCK -- Base docker images off of DOCK
11 | # -c, --clean -------- clean up docker images
12 | #
13 | OUTDIR=$(pwd)
14 | SCRIPT="$0"
15 | INNER_SCRIPT="$(dirname $(readlink -f ${SCRIPT}))/try-all-cdbs-in-image-loop.sh"
16 | DOCK=
17 | CLEAN=
18 | help(){
19 | local HELP_TEXT=$(cat "$SCRIPT" \
20 | |sed '/^[^#]/q' \
21 | |head -n -1 \
22 | |tail -n +3 \
23 | |sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' \
24 | |cut -c3-)
25 | echo "$HELP_TEXT"
26 | exit 1
27 | }
28 |
29 | eval set -- $(getopt -o ho:d:c -l help,outdir:,docker:,clean -- "$@" || help;)
30 | while [ $# -gt 0 ];do
31 | case $1 in
32 | -h|--help) help;;
33 | -o|--outdir) OUTDIR=$(readlink -f $2); shift;;
34 | -d|--docker) DOCK=$2; shift;;
35 | -c|--clean) CLEAN=yes;;
36 | (--) shift; break;;
37 | (-*) error "unrecognized option $1";;
38 | (*) break;;
39 | esac
40 | shift
41 | done
42 |
43 | if [ -z $1 ];then
44 | help
45 | fi
46 |
47 | for REPO in $@;do
48 | pushd $REPO
49 | IMAGE="$(basename $REPO|tr '[A-Z]' '[a-z]')-cdb"
50 | git checkout master -- gt-harness.sh
51 | sed -i '/^.git/d' .dockerignore
52 | ./gt-harness.sh docker ${IMAGE} ${DOCK}
53 | docker run -v ${INNER_SCRIPT}:/try-all-cdbs-in-image-loop.sh -v ${OUTDIR}:/cdbs ${IMAGE} /try-all-cdbs-in-image-loop.sh
54 | if [ ! -z ${CLEAN} ];then
55 | docker rmi -f ${IMAGE}
56 | fi
57 | popd
58 | done
59 |
--------------------------------------------------------------------------------
/exp/bin/try-all-cdbs-in-image-loop.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ ! -f gt-harness-common.sh ];then
3 | echo "missing gt-harness-common.sh"
4 | exit 1
5 | else
6 | cp gt-harness-common.sh /gt-harness-common.sh
7 | fi
8 | if [ ! -f gt-harness.sh ];then
9 | echo "missing gt-harness.sh"
10 | exit 1
11 | else
12 | cp gt-harness.sh /gt-harness.sh
13 | fi
14 |
15 | TOTAL=$(git rev-list --all --count)
16 | COUNT=0
17 | FAIL=0
18 | for COMMIT in $(git rev-list --all);do
19 | ((COUNT++))
20 | printf "\r%6d/%d\t%s" $COUNT $TOTAL $COMMIT
21 | git reset --hard $COMMIT >/dev/null 2>/dev/null
22 | git clean -fdx >/dev/null 2>/dev/null
23 | cp /gt-harness-common.sh ./ || exit 1
24 | cp /gt-harness.sh ./ || exit 1
25 | (./gt-harness.sh prep && bear ./gt-harness.sh build) >/dev/null 2>/dev/null
26 | if [ $? -eq 0 ];then
27 | mv compile_commands.json /cdbs/${COMMIT}.json
28 | else
29 | touch /cdbs/${COMMIT}.fail
30 | ((FAIL++))
31 | fi >/dev/null 2>/dev/null
32 | done
33 | printf "\n%6d/%d\tFAILED\n" $FAIL $TOTAL
34 |
--------------------------------------------------------------------------------
/exp/bin/try-all-merges:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Usage: try-all-merges BENCHMARKDIR [-- DIFF-OPTIONS...]
4 | #
5 | # Read conflict lines of format
6 | # "benchmark base left right"
7 | # from STDIN and run try-merges on benchmarks in BENCHMARKDIR
8 | #
9 | # OPTIONS:
10 | # -h,--help ---------- print this help information
11 | # -d,--diff DIFF ----- diff tool to use to compute patches
12 | # default to diff3
13 | # -l,--local --------- pass the 'local' option to git clone
14 | # -w,--workdir DIR --- set the working directory
15 | # defaults to the current directory
16 | # -b, --build BUILD -- Use BUILD to make compilation database
17 | # -i ----------------- Copy workdir into a separate numbered
18 | # directory for each merge
19 | #
20 | LOCAL=
21 | WORKDIR=
22 | DIFF=diff3
23 | SCRIPT="$0"
24 | BUILD=
25 | WORKCOPY=
26 | help(){
27 | local HELP_TEXT=$(cat "$SCRIPT" \
28 | |sed '/^[^#]/q' \
29 | |head -n -1 \
30 | |tail -n +3 \
31 | |sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' \
32 | |cut -c3-)
33 | echo "$HELP_TEXT"
34 | exit 1
35 | }
36 |
37 | eval set -- $(getopt -o ihlb:w:d: -l help,local,build:,workdir:,diff: -- "$@" || help;)
38 | while [ $# -gt 0 ];do
39 | case $1 in
40 | -h|--help) help;;
41 | -i) WORKCOPY=y;;
42 | -l|--local) LOCAL=--local;;
43 | -b|--build) BUILD=$2; shift;;
44 | -w|--workdir) WORKD=$2; WORKDIR="--workdir $2"; shift;;
45 | -d|--diff) DIFF=$2; shift;;
46 | (--) shift; break;;
47 | (-*) error "unrecognized option $1";;
48 | (*) break;;
49 | esac
50 | shift
51 | done
52 | echo "BUILD="${BUILD}
53 |
54 | if [ -z $1 ];then
55 | help
56 | else
57 | BENCHMARKDIR=$1
58 | shift
59 | fi
60 |
61 | COUNT=1
62 | while IFS=" " read name base left right;do
63 | if [ ${WORKCOPY} = "y" ]; then
64 | WORKDIR="--workdir ${WORKD}-${COUNT}"
65 | COUNT=$((COUNT+1))
66 | fi
67 | try-merge --diff ${DIFF} ${LOCAL} ${WORKDIR} --build "${BUILD}" \
68 | ${BENCHMARKDIR}/${name} ${base} ${left} ${right} \
69 | -- $@
70 | done
71 |
--------------------------------------------------------------------------------
/exp/bin/try-stats:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Collect diff3 stats from dirs in $@
4 | #
5 | STATS=
6 |
7 | stats_for(){
8 | echo "${STATS}"\
9 | |grep -c "\.$1$"; }
10 |
11 | for dir in $@;do
12 | STATS="$(find ${dir} -type f)"
13 | echo -e "${dir}\t$(stats_for 0)\t$(stats_for 1)\t$(stats_for 2)\t$(stats_for no-base)\t$(stats_for just-base)\t$(stats_for no-left)\t$(stats_for just-left)\t$(stats_for no-right)\t$(stats_for just-right)"
14 | done
15 |
--------------------------------------------------------------------------------
/exp/bin/try-tss:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | PROG=the_silver_searcher
3 | rm -rf ${PROG}-base ${PROG}-left ${PROG}-right
4 | try-all-merges --bear ./build.sh -d ast-merge /pdietz/ < ${PROG}-conflicts
5 |
--------------------------------------------------------------------------------
/exp/conflicts/tss:
--------------------------------------------------------------------------------
1 | the_silver_searcher b4215ac1057adde21dbcc2b4f58f3b57d5fe7217 0d1d5fb 4175763
2 | the_silver_searcher 7081236fc51bca512a119d6a4f3f8bec46f636f1 347d336 de1a600
3 | the_silver_searcher 1a1c3fce7b87ecc4ff4b9a9b8b0ecc5c9c010bf9 fc6de67 2af06a8
4 | the_silver_searcher 13075bb99f6369452b4bb5b0ef2e8f801c31e18a 9e7ad9d 42db5eb
5 | the_silver_searcher f6199062f0ebf1e83802ad76f1dc0f621b0549e8 b64de8f ee0e507
6 |
--------------------------------------------------------------------------------
/exp/conflicts/tss-all:
--------------------------------------------------------------------------------
1 | the_silver_searcher b4215ac1057adde21dbcc2b4f58f3b57d5fe7217 0d1d5fb 4175763
2 | the_silver_searcher 36754027ac4f44c1d4329ee2b4fa1b112b6c3e45 feca477 f3c1d86
3 | the_silver_searcher 630125a9242ae20721959563fbd500635820b8a1 deb3e96 5ce4215
4 | the_silver_searcher 7081236fc51bca512a119d6a4f3f8bec46f636f1 347d336 de1a600
5 | the_silver_searcher 1a1c3fce7b87ecc4ff4b9a9b8b0ecc5c9c010bf9 fc6de67 2af06a8
6 | the_silver_searcher 13075bb99f6369452b4bb5b0ef2e8f801c31e18a 9e7ad9d 42db5eb
7 | the_silver_searcher f6199062f0ebf1e83802ad76f1dc0f621b0549e8 b64de8f ee0e507
8 |
--------------------------------------------------------------------------------
/exp/conflicts/tss-crashing:
--------------------------------------------------------------------------------
1 | the_silver_searcher 36754027ac4f44c1d4329ee2b4fa1b112b6c3e45 feca477 f3c1d86
2 | the_silver_searcher 630125a9242ae20721959563fbd500635820b8a1 deb3e96 5ce4215
3 |
--------------------------------------------------------------------------------
/exp/pub/.gitignore:
--------------------------------------------------------------------------------
1 | *.4ct
2 | *.4tc
3 | *.aux
4 | *.auxlock
5 | *.bak
6 | *.bbl
7 | *.blg
8 | *.bll
9 | *.css
10 | *.dep
11 | *.docx
12 | *.dot
13 | *.dpth
14 | *.dvi
15 | *.eps
16 | *.fdb_latexmk
17 | *.fls
18 | *.glg
19 | *.glo
20 | *.gls
21 | *.glsdefs
22 | *.html
23 | *.idv
24 | *.lg
25 | *.lof
26 | *.log
27 | *.lot
28 | *.md5
29 | *.nav
30 | *.out
31 | *.pdf
32 | *.png
33 | *.snm
34 | *.svg
35 | *.tex~
36 | *.tmp
37 | *.toc
38 | *.vrb
39 | *.xdy
40 | *.xref
41 | *.zip
42 |
--------------------------------------------------------------------------------
/exp/pub/Makefile:
--------------------------------------------------------------------------------
1 | TARGET ?= main
2 | PDFLATEX_OPTS = -interactive=nonstopmode \
3 | -halt-on-error \
4 | -file-line-error \
5 | -shell-escape
6 | LATEXMK = latexmk
7 | LATEXMK_FLAGS = -f -pdf -pdflatex="pdflatex $(PDFLATEX_OPTS)" -use-make
8 |
9 | all: $(TARGET).pdf
10 |
11 | .PHONY: watch
12 |
13 | watch: $(TARGET).tex
14 | -$(LATEXMK) -pvc $(LATEXMK_FLAGS) -jobname=$(TARGET) $<
15 |
16 | %.pdf: %.tex
17 | -latexmk -f -pdf -pdflatex="pdflatex -interactive=nonstopmode -halt-on-error -file-line-error" -use-make $<
18 |
19 | main.zip: *.tex main-figure0.pdf main-figure1.pdf main.bbl usenix2019_v3.sty
20 | zip main $^
21 |
22 | clean:
23 | -@latexmk -CA
24 | -@rm -f *.{bbl,snm,nav,vrb,glo,fls,log,toc,xdy,fls,lof,lot,out,fdb_latexmk}
25 |
26 | real-clean: clean
27 | -@rm -f *-figure*.{dep,dpth,md5,pdf}
28 |
--------------------------------------------------------------------------------
/exp/pub/acknowledgments.tex:
--------------------------------------------------------------------------------
1 | \section{Acknowledgments}
2 |
--------------------------------------------------------------------------------
/exp/pub/conclusion.tex:
--------------------------------------------------------------------------------
1 | \section{Conclusion}
2 |
--------------------------------------------------------------------------------
/exp/pub/experiments.tex:
--------------------------------------------------------------------------------
1 | \section{Experiments}
2 |
--------------------------------------------------------------------------------
/exp/pub/intro.tex:
--------------------------------------------------------------------------------
1 | \section{Introduction}
2 |
--------------------------------------------------------------------------------
/exp/pub/main.tex:
--------------------------------------------------------------------------------
1 | \documentclass[letterpaper,twocolumn,10pt]{article}
2 | \usepackage{latexsym,amssymb,stmaryrd}
3 | \usepackage{amsmath}
4 | \usepackage{amsthm}
5 | \usepackage{colortbl}
6 | \usepackage{color}
7 | \usepackage{graphics}
8 | \usepackage{graphicx}
9 | \usepackage{tikz}
10 | \usepackage{multicol}
11 | \usepackage{multirow}
12 | \usepackage{url}
13 | \usepackage{arydshln}
14 | \usepackage{pgfplots}
15 | \usepackage{listings}
16 | \usepackage{todo}
17 | \usepackage{longtable}
18 |
19 | \usepgfplotslibrary{external}
20 | \tikzexternalize
21 |
22 | \let\labelindent\relax
23 | \usepackage{enumitem}
24 |
25 | \usepackage{ctable}
26 | \lstset{
27 | frame=Ltb,
28 | framerule=0pt,
29 | %aboveskip=1em,
30 | framextopmargin=0pt,
31 | framexbottommargin=0pt,
32 | framexleftmargin=0cm,
33 | framesep=0pt,
34 | rulesep=0pt,
35 | %
36 | stringstyle=\small\ttfamily,
37 | keepspaces=true,
38 | basicstyle=\fontencoding{T1}\small\fontfamily{cmtt}\selectfont\upshape,
39 | %basicstyle=\small\sffamily\upshape,
40 | showstringspaces = false,
41 | mathescape=true,
42 | breaklines=true,
43 | columns=fullflexible,
44 | %language=Prolog
45 | }
46 |
47 | \begin{document}
48 |
49 | \title{Automated Merge-conflict Resolution with Semantic Differencing}
50 |
51 | \author{
52 | {\rm Paul Dietz}\\
53 | GrammaTech, Inc.\\
54 | {\tt pdietz@grammatech.com}
55 | \and
56 | {\rm Jason Ruchti}\\
57 | GrammaTech, Inc.\\
58 | {\tt jruchti@grammatech.com}
59 | \and
60 | {\rm Eric Schulte}\\
61 | GrammaTech, Inc.\\
62 | {\tt eschulte@grammatech.com}
63 | }
64 |
65 | \maketitle
66 |
67 | \begin{abstract}
68 | Resolve implements multi-lingual semantic differencing of software
69 | source code and implements an automated technique of merge conflict
70 | resolution on top of merge conflicts over the resulting differences.
71 | \end{abstract}
72 |
73 | \input{intro}
74 | \input{related}
75 | \input{methodology}
76 | \input{experiments}
77 | \input{conclusion}
78 | \input{acknowledgments}
79 |
80 | \bibliographystyle{plain}
81 | \bibliography{bibliography}
82 |
83 | \end{document}
84 |
--------------------------------------------------------------------------------
/exp/pub/methodology.tex:
--------------------------------------------------------------------------------
1 | \section{Methodology}
2 |
--------------------------------------------------------------------------------
/exp/pub/related.tex:
--------------------------------------------------------------------------------
1 | \section{Related Work}
2 |
--------------------------------------------------------------------------------
/html.lisp:
--------------------------------------------------------------------------------
1 | ;;; ast-diff-html.lisp --- render ast diffs to html
2 | (defpackage :resolve/html
3 | (:use :gt/full
4 | :resolve/ast-diff
5 | :cl-who)
6 | (:shadowing-import-from :cl-who :fmt :escape-string)
7 | (:export :diff-to-html))
8 | (in-package :resolve/html)
9 |
10 | (defun diff-to-html (orig-asts edit-script &optional (stream t))
11 | "Generate HTML which shows side-by-side diff.
12 |
13 | Shows source text of ORIG-ASTS alongside the result of applying
14 | EDIT-SCRIPT, with highlighting of inserts and deletes.
15 | "
16 | (labels
17 | ((render-ast (ast)
18 | (let ((text (source-text ast)))
19 | (values (escape-string text) (count #\newline text))))
20 | (render-diff (asts script)
21 | (if (null script)
22 | '(nil nil)
23 | (destructuring-bind (action . args) (car script)
24 | (ecase action
25 | (:recurse
26 | (mapcar #'append
27 | (render-diff (cdr (car asts)) args)
28 | (render-diff (cdr asts) (cdr script))))
29 | (:same
30 | (mapcar #'cons
31 | (make-list 2
32 | :initial-element
33 | (render-ast (car asts)))
34 | (render-diff (cdr asts) (cdr script))))
35 | (:delete
36 | (multiple-value-bind (text line-count)
37 | (render-ast (car asts))
38 | (mapcar #'cons
39 | (list (format nil
40 | "~a"
41 | text)
42 | (format nil "~{~a~}"
43 | (make-list line-count
44 | :initial-element
45 | #\newline)))
46 | (render-diff (cdr asts) (cdr script)))))
47 | (:insert
48 | (multiple-value-bind (text line-count)
49 | (render-ast args)
50 | (mapcar #'cons
51 | (list (format nil "~{~a~}"
52 | (make-list line-count
53 | :initial-element
54 | #\newline))
55 | (format nil
56 | "~a"
57 | text))
58 | (render-diff asts (cdr script))))))))))
59 | (apply #'format stream "
60 |
61 |
62 |
88 |
89 |
90 |
91 |
92 |
93 | "
94 | (traced (render-diff orig-asts edit-script)))))
95 |
--------------------------------------------------------------------------------
/js/ast-diff.js:
--------------------------------------------------------------------------------
1 | renderDiff = () => {
2 | var diff = JSON.parse(document.getElementById('diff').innerHTML)
3 | var page = document.getElementById('page')
4 | page.innerHTML += "\n"
5 | diff.forEach(item => {
6 | page.innerHTML += `${item[1]}`
7 | })
8 | }
9 |
--------------------------------------------------------------------------------
/resolve.asd:
--------------------------------------------------------------------------------
1 | (defsystem "resolve"
2 | :description "Software difference resolution"
3 | :depends-on (resolve/core)
4 | :version "0.0.0"
5 | :class :package-inferred-system
6 | :defsystem-depends-on (:asdf-package-system)
7 | :in-order-to ((test-op (load-op "resolve/test")))
8 | :perform (test-op (o c) (symbol-call :resolve/test '#:run-batch)))
9 |
10 | (register-system-packages "resolve/core" '(:resolve))
11 | (register-system-packages "fare-quasiquote-extras" '(:fare-quasiquote))
12 | (register-system-packages "trivia" '(:trivia.fail))
13 |
14 | (defsystem "resolve/run-ast-diff"
15 | :author "GrammaTech"
16 | :description "Calculate difference between two programs."
17 | :version "0.0.0"
18 | :depends-on (resolve/commands)
19 | :build-operation "asdf:program-op"
20 | :build-pathname "bin/ast-diff"
21 | :entry-point "resolve/commands::run-ast-diff")
22 |
23 | (defsystem "resolve/run-serve-ast-diff"
24 | :description "REST `ast-diff' server from resolve."
25 | :depends-on ("resolve/routes/diff")
26 | :build-operation "asdf:program-op"
27 | :build-pathname "bin/serve-ast-diff"
28 | :entry-point "resolve/commands::run-serve-ast-diff")
29 |
30 | (defsystem "resolve/run-serve-auto-merge"
31 | :description "REST `auto-merge' server from resolve."
32 | :depends-on ("resolve/routes/merge")
33 | :build-operation "asdf:program-op"
34 | :build-pathname "bin/serve-auto-merge"
35 | :entry-point "resolve/commands::run-serve-auto-merge")
36 |
37 | (defsystem "resolve/run-ast-merge"
38 | :author "GrammaTech"
39 | :description "Merge two programs that diverge from a common ancestor."
40 | :version "0.0.0"
41 | :depends-on (resolve/commands)
42 | :build-operation "asdf:program-op"
43 | :build-pathname "bin/ast-merge"
44 | :entry-point "resolve/commands::run-ast-merge")
45 |
46 | (defsystem "resolve/run-auto-merge"
47 | :author "GrammaTech"
48 | :description "Automatically two programs (w/ancestor) against a test script."
49 | :version "0.0.0"
50 | :depends-on (resolve/commands)
51 | :build-operation "asdf:program-op"
52 | :build-pathname "bin/auto-merge"
53 | :entry-point "resolve/commands::run-auto-merge")
54 |
--------------------------------------------------------------------------------
/routes/diff.lisp:
--------------------------------------------------------------------------------
1 | (defpackage :resolve/routes/diff
2 | (:use :gt/full :resolve/commands)
3 | (:import-from :snooze :defroute))
4 | (in-package :resolve/routes/diff)
5 |
6 | (defroute diff (:post :application/json)
7 | (with-output-to-string (*standard-output*)
8 | (rest-diff :json t)))
9 |
10 | (defroute diff (:post :text/plain)
11 | (with-output-to-string (*standard-output*)
12 | (rest-diff)
13 | (format t "~&")))
14 |
15 | (defroute show (:get :text/html hash)
16 | (render-json-diff-to-html (lookup-json-diff-hash (symbol-name hash))))
17 |
18 | (defroute diff (:post :text/html)
19 | (render-json-diff-to-html (with-output-to-string (*standard-output*)
20 | (rest-diff :json t))))
21 |
--------------------------------------------------------------------------------
/routes/merge.lisp:
--------------------------------------------------------------------------------
1 | (defpackage :resolve/routes/merge
2 | (:use :gt/full :resolve/commands)
3 | (:import-from :snooze :defroute))
4 | (in-package :resolve/routes/merge)
5 |
--------------------------------------------------------------------------------
/software/lisp.lisp:
--------------------------------------------------------------------------------
1 | (defpackage :resolve/software/lisp
2 | (:use :gt/full
3 | :resolve/ast-diff
4 | :software-evolution-library
5 | :software-evolution-library/software/parseable
6 | :software-evolution-library/software/lisp)
7 | (:import-from :resolve/ast-diff :ast-class))
8 | (in-package :resolve/software/lisp)
9 | (in-readtable :curry-compose-reader-macros)
10 |
11 | (defmethod ast-can-recurse ((ast-a sel/sw/lisp::lisp-ast) (ast-b sel/sw/lisp::lisp-ast))
12 | (and (eq (ast-class ast-a) (ast-class ast-b))
13 | (or (not (eql :expression (ast-class ast-a)))
14 | ;; Special handling for lisp expression ASTs.
15 | ;; Don't descend into atomic expressions.
16 | (not (or (atom (aget :expression (ast-annotations ast-a)))
17 | (atom (aget :expression (ast-annotations ast-b))))))))
18 |
--------------------------------------------------------------------------------
/software/parseable.lisp:
--------------------------------------------------------------------------------
1 | (defpackage :resolve/software/parseable
2 | (:use :gt/full
3 | :resolve/ast-diff
4 | :software-evolution-library
5 | :software-evolution-library/software/parseable)
6 | (:import-from :resolve/ast-diff :ast-diff* :ast-patch*)
7 | (:import-from :software-evolution-library/software/tree-sitter
8 | :source-text-fragment-variation-point)
9 | (:export ast-stub))
10 | (in-package :resolve/software/parseable)
11 | (in-readtable :curry-compose-reader-macros)
12 |
13 | ;;; TODO: using source-text-fragment-variation-point here is a bit of
14 | ;;; a hack, but it isn't strictly incorrect. Maybe find a better
15 | ;;; way to do this in the future. NOTE: This used to inherit
16 | ;;; directly from source-text-fragment, but that's no longer
17 | ;;; considered a wildcard, so we use
18 | ;;; source-text-fragment-variation-point, which is.
19 | (defclass ast-stub (source-text-fragment-variation-point functional-tree-ast)
20 | ((children :type list
21 | :initarg :children
22 | :initform nil
23 | :documentation "The list of children of the node,
24 | which may be more nodes, or other values.")
25 | (child-slots :initform '(children) :allocation :class))
26 | (:documentation "Minimal concrete subclass of AST useful a placeholder
27 | where an AST is expected. ast-stub is used to represent a conflict
28 | resolution where the AST is removed. A stub is inserted and the
29 | original conflict AST is stored as an annotation; in future mutations,
30 | we can try a different conflict solution by examining the ast stub's
31 | conflict AST annotation and selecting a different resolution"))
32 |
33 | (defmethod ast-diff* ((parseable-a parseable) (parseable-b parseable))
34 | #+debug (format t "ast-diff[PARSEABLE]~%")
35 | (ast-diff* (genome parseable-a) (genome parseable-b)))
36 |
37 | (defmethod create-edit-tree ((source parseable) (target parseable) script
38 | &rest args &key &allow-other-keys)
39 | (apply #'create-edit-tree (genome source) (genome target) script args))
40 |
41 | (defmethod ast-patch* ((obj parseable) (diff list)
42 | &rest keys &key &allow-other-keys)
43 | (setf obj (copy obj))
44 | (setf (genome obj) (apply #'ast-patch* (genome obj) diff keys))
45 | obj)
46 |
47 | (defmethod converge ((obj2 parseable) (obj1 parseable) (obj3 parseable)
48 | &rest args &key &allow-other-keys)
49 | (copy obj1
50 | :genome (apply #'converge
51 | (genome obj2)
52 | (genome obj1)
53 | (genome obj3)
54 | args)))
55 |
--------------------------------------------------------------------------------
/software/project.lisp:
--------------------------------------------------------------------------------
1 | (defpackage :resolve/software/project
2 | (:use :gt/full
3 | :resolve/ast-diff
4 | :resolve/alist
5 | :software-evolution-library
6 | :software-evolution-library/software/project)
7 | (:import-from :resolve/ast-diff :ast-diff* :ast-patch*))
8 | (in-package :resolve/software/project)
9 | (in-readtable :curry-compose-reader-macros)
10 |
11 | (defun confirm-files-are-same (alist1 alist2)
12 | (let ((files1 (mapcar #'car alist1))
13 | (files2 (mapcar #'car alist2)))
14 | (unless (equal files1 files2)
15 | (error "Two file alists do not reference the same files: ~A, ~A" files1 files2))))
16 |
17 | (defun sort-file-alist (alist)
18 | (sort (copy-list alist) #'string< :key (lambda (x) (string (car x)))))
19 |
20 | (defmethod ast-diff* ((project1 project) (project2 project))
21 | #+debug (format t "ast-diff[PROJECT]~%")
22 | (flet ((%obj (proj) (make-instance 'alist-for-diff :alist (all-files proj))))
23 | (ast-diff* (%obj project1) (%obj project2))))
24 |
25 | (defun make-table-for-alist (alist &key (test #'eql))
26 | (let ((tab (make-hash-table :test test)))
27 | (iter (for p in alist)
28 | (when p
29 | (setf (gethash (car p) tab) p)))
30 | tab))
31 |
32 | (defun remove-files-not-in (files1 files2)
33 | (let ((ntab (make-table-for-alist files2 :test #'equal)))
34 | (remove-if-not (lambda (p) (gethash (car p) ntab)) files1)))
35 |
36 | (defmethod ast-patch* ((project project) (diff t)
37 | &rest args &key &allow-other-keys)
38 | (let* ((files-obj (make-instance 'alist-for-diff
39 | :alist (all-files project)))
40 | (new-files-obj (apply #'ast-patch* files-obj diff args))
41 | (new-project (copy project))
42 | (evolve-files-table (make-table-for-alist (evolve-files new-project)
43 | :test #'equal))
44 | (result-alist (alist-of-alist-for-diff new-files-obj)))
45 | (flet ((evolve? (p) (gethash (car p) evolve-files-table)))
46 | (let ((new-evolve-files (remove-if-not #'evolve? result-alist))
47 | (new-other-files (remove-if #'evolve? result-alist)))
48 | (setf (evolve-files new-project) new-evolve-files
49 | (other-files new-project) new-other-files)))
50 | new-project))
51 |
--------------------------------------------------------------------------------
/test/bin/ast-diff-on-json-has-lines:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Due to a temporary bug, diff files did not have newlines.
4 | #
5 | . $(dirname $0)/common
6 |
7 | DIFF="$(ast-diff test/etc/javascript/package-json/d5da5eb.json \
8 | test/etc/javascript/package-json/ea14630.json)"
9 | if [ $(echo "$DIFF"|wc -l) -gt 10 ];then
10 | echo PASS
11 | exit 0
12 | else
13 | echo FAIL
14 | exit 1
15 | fi
16 |
--------------------------------------------------------------------------------
/test/bin/ast-diff-on-lisp-has-lines:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Due to a temporary bug, diff files did not have newlines.
4 | #
5 | . $(dirname $0)/common
6 |
7 | DIFF="$(ast-diff test/etc/gcd/gcd.lisp \
8 | test/etc/gcd/gcd-fix.lisp)"
9 | if [ $(echo "$DIFF"|wc -l) -gt 10 ];then
10 | echo PASS
11 | exit 0
12 | else
13 | echo FAIL
14 | exit 1
15 | fi
16 |
--------------------------------------------------------------------------------
/test/bin/ast-diff-on-simple-has-lines:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Due to a temporary bug, diff files did not have newlines.
4 | #
5 | . $(dirname $0)/common
6 |
7 | DIFF="$(ast-diff test/etc/simple/seq-10.txt \
8 | test/etc/simple/seq-10-edit.txt)"
9 | if [ $(echo "$DIFF"|wc -l) -gt 9 ];then
10 | echo PASS
11 | exit 0
12 | else
13 | echo FAIL
14 | exit 1
15 | fi
16 |
--------------------------------------------------------------------------------
/test/bin/ast-merge-json-has-conflict:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Error on missing method merging package files with --conflict
4 | #
5 | . $(dirname $0)/common
6 |
7 | ast-merge --conflict test/etc/javascript/package-json/{ea14630,d5da5eb,6655688}.json
8 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-gcd-project:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge the gcd project by trying all
4 | # possibilities of conflict resolution prior to
5 | # beginning the evolutionary loop.
6 |
7 | . $(dirname $0)/common
8 |
9 | test_auto_merge $ETC_DIR/gcd-project-auto-merge \
10 | gcd-1 \
11 | gcd-2 \
12 | gcd-3 \
13 | --num-tests 11 \
14 | --num-threads 2 \
15 | --build-command make \
16 | --artifacts gcd
17 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-gcd-project-delete-file-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge the gcd project with a file deletion
4 | # in the evolutionary loop.
5 |
6 | . $(dirname $0)/common
7 |
8 | test_auto_merge $ETC_DIR/gcd-project-delete-file-auto-merge \
9 | gcd-1 \
10 | gcd-2 \
11 | gcd-3 \
12 | --num-tests 11 \
13 | --num-threads 2 \
14 | --build-command make \
15 | --artifacts gcd \
16 | --pop-size 1 \
17 | --evolve
18 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-gcd-project-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge the gcd project in the evolutionary
4 | # loop by creating a single conflict resolution variant
5 | # and repeatedly mutating it.
6 |
7 | . $(dirname $0)/common
8 |
9 | test_auto_merge $ETC_DIR/gcd-project-auto-merge \
10 | gcd-1 \
11 | gcd-2 \
12 | gcd-3 \
13 | --num-tests 11 \
14 | --num-threads 2 \
15 | --build-command make \
16 | --artifacts gcd \
17 | --pop-size 1 \
18 | --evolve
19 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-gcd-project-insert-file-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge the gcd project with a file insertion
4 | # in the evolutionary loop.
5 |
6 | . $(dirname $0)/common
7 |
8 | test_auto_merge $ETC_DIR/gcd-project-insert-file-auto-merge \
9 | gcd-1 \
10 | gcd-2 \
11 | gcd-3 \
12 | --num-tests 11 \
13 | --num-threads 2 \
14 | --build-command make \
15 | --artifacts gcd \
16 | --pop-size 1 \
17 | --evolve
18 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-gcd-single-file:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge single-file gcd variants by
4 | # trying all possibilities of conflict resolution prior to
5 | # beginning the evolutionary loop.
6 |
7 | . $(dirname $0)/common
8 |
9 | test_auto_merge $ETC_DIR/gcd-single-file-auto-merge \
10 | gcd-1.c \
11 | gcd-2.c \
12 | gcd-3.c \
13 | --num-tests 11 \
14 | --num-threads 2
15 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-gcd-single-file-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge single-file gcd variants in the
4 | # evolutionary loop by creating a single conflict resolution
5 | # and repeatedly mutating it.
6 |
7 | . $(dirname $0)/common
8 |
9 | test_auto_merge $ETC_DIR/gcd-single-file-auto-merge \
10 | gcd-1.c \
11 | gcd-2.c \
12 | gcd-3.c \
13 | --num-tests 11 \
14 | --num-threads 2 \
15 | --pop-size 1 \
16 | --evolve
17 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-text-project:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge a text project by trying all
4 | # possibilities of conflict resolution prior to
5 | # beginning the evolutionary loop.
6 |
7 | . $(dirname $0)/common
8 |
9 | test_auto_merge $ETC_DIR/text-project-auto-merge \
10 | text1 \
11 | text2 \
12 | text3 \
13 | --num-tests 3 \
14 | --language javascript
15 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-text-project-delete-file-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge a text project with a file deletion
4 | # in the evolutionary loop.
5 |
6 | . $(dirname $0)/common
7 |
8 | test_auto_merge $ETC_DIR/text-project-delete-file-auto-merge \
9 | text1 \
10 | text2 \
11 | text3 \
12 | --num-tests 3 \
13 | --language javascript \
14 | --pop-size 1 \
15 | --evolve
16 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-text-project-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge a text project in the evolutionary
4 | # loop by creating a single conflict resolution variant
5 | # and repeatedly mutating it.
6 |
7 | . $(dirname $0)/common
8 |
9 | test_auto_merge $ETC_DIR/text-project-auto-merge \
10 | text1 \
11 | text2 \
12 | text3 \
13 | --num-tests 3 \
14 | --language javascript \
15 | --pop-size 1 \
16 | --evolve
17 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-text-project-insert-file-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge a text project with a file insertion
4 | # in the evolutionary loop.
5 |
6 | . $(dirname $0)/common
7 |
8 | test_auto_merge $ETC_DIR/text-project-insert-file-auto-merge \
9 | text1 \
10 | text2 \
11 | text3 \
12 | --num-tests 3 \
13 | --language javascript \
14 | --pop-size 1 \
15 | --evolve
16 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-text-single-file:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge single text files by
4 | # trying all possibilities of conflict resolution
5 | # prior to beginning the evolutionary loop.
6 | . $(dirname $0)/common
7 |
8 | test_auto_merge $ETC_DIR/text-single-file-auto-merge \
9 | text1 \
10 | text2 \
11 | text3 \
12 | --num-tests 3
13 |
--------------------------------------------------------------------------------
/test/bin/can-auto-merge-text-single-file-evolve:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Test we can auto-merge text file variants in the
4 | # evolutionary loop by creating a single conflict
5 | # resolution and repeatedly mutating it.
6 |
7 | . $(dirname $0)/common
8 |
9 | test_auto_merge $ETC_DIR/text-single-file-auto-merge \
10 | text1 \
11 | text2 \
12 | text3 \
13 | --num-tests 3 \
14 | --pop-size 1 \
15 | --evolve
16 |
--------------------------------------------------------------------------------
/test/bin/clang-diff-on-gcd:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | . $(dirname $0)/common
3 |
4 | NUM_DIFFS="$(ast-diff --strings test/etc/gcd/gcd-wo-curlies.c test/etc/gcd/gcd-wo-curlies-fix.c|grep -c "{+")"
5 | if [ "$NUM_DIFFS" == "1" ];then
6 | echo PASS
7 | exit 0
8 | else
9 | echo FAIL
10 | exit 1
11 | fi
12 |
--------------------------------------------------------------------------------
/test/bin/clang-diff-on-gcd-edit-tree:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | . $(dirname $0)/common
3 |
4 | C=`(ast-diff --edit-tree test/etc/gcd/gcd-wo-curlies.c test/etc/gcd/gcd-wo-curlies-fix.c|grep Coherence|wc -l)`
5 | if [ "$C" == "2" ];then
6 | echo PASS
7 | exit 0
8 | else
9 | echo FAIL
10 | exit 1
11 | fi
12 |
--------------------------------------------------------------------------------
/test/bin/clang-diff-on-gcd-edit-tree-coherence:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | . $(dirname $0)/common
3 |
4 | C=`(ast-diff --edit-tree --coherence 0.04 test/etc/gcd/gcd-wo-curlies.c test/etc/gcd/gcd-wo-curlies-fix.c|grep Coherence|wc -l)`
5 | if [ "$C" == "1" ];then
6 | echo PASS
7 | exit 0
8 | else
9 | echo FAIL
10 | exit 1
11 | fi
12 |
--------------------------------------------------------------------------------
/test/bin/common:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | SCRIPT="$0"
4 | ETC_DIR="$(readlink -f $(dirname $0)/../etc/)"
5 | export PATH=$PATH:${QUICK_LISP:-${HOME}/quicklisp}/local-projects/resolve/bin
6 |
7 | help(){
8 | local DESCRIPTION=$(cat "$SCRIPT" \
9 | |sed '/^[^#]/q' \
10 | |head -n -1 \
11 | |tail -n +3 \
12 | |sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' \
13 | |cut -c3- \
14 | |sed 's/^/ /')
15 | echo "$DESCRIPTION"
16 | echo "Options:"
17 | echo " -h,--help --------- Print this help output then exit"
18 | echo " -v,--verbose ------ Verbose mode with 'set -x' on script"
19 | echo " -k,--keep --------- Keep temporary files after execution"
20 | echo " --out-dir ------ Pass given out-dir to program under test"
21 | echo ""
22 | exit 0; }
23 |
24 | eval set -- $(getopt -o hvko: -l help,verbose,keep,out-dir: -- "$@" || help;)
25 | while [ $# -gt 0 ];do
26 | case $1 in
27 | -h|--help) help;;
28 | -v|--verbose) set -x;;
29 | -k|--keep) KEEP_TMP=YES;;
30 | --out-dir) OUT_DIR=$(readlink -f $2); shift ;;
31 | (--) shift; break;;
32 | (-*) error "unrecognized option $1";;
33 | (*) break;;
34 | esac
35 | shift
36 | done
37 |
38 | # Execute an auto-merge test
39 | # $1 - Base directory containing MY, OLD, and YOUR variants to merge
40 | # $2 - MY variant
41 | # $3 - OLD variant
42 | # $4 - YOUR variant
43 | # $@ - Remaining arguments to pass thru to auto-merge
44 | test_auto_merge () {
45 | BASE_DIR=$1
46 | TMP_OUTPUT=$(mktemp)
47 |
48 | if [ -d $BASE_DIR/$2 ]; then
49 | TMP_MY=$(mktemp -d)
50 | TMP_OLD=$(mktemp -d)
51 | TMP_YOUR=$(mktemp -d)
52 | cp -pr $BASE_DIR/$2/* $TMP_MY/
53 | cp -pr $BASE_DIR/$3/* $TMP_OLD/
54 | cp -pr $BASE_DIR/$4/* $TMP_YOUR/
55 | else
56 | TMP_DIR=$(mktemp -d)
57 | TMP_MY=$TMP_DIR/$2
58 | TMP_OLD=$TMP_DIR/$3
59 | TMP_YOUR=$TMP_DIR/$4
60 | cp -p $BASE_DIR/$2 $TMP_MY
61 | cp -p $BASE_DIR/$3 $TMP_OLD
62 | cp -p $BASE_DIR/$4 $TMP_YOUR
63 | fi
64 |
65 | TEST_SCRIPT="$BASE_DIR/test.sh ~a ~d"
66 | TMP_OUT_DIR=$(mktemp -d)
67 | shift 4;
68 |
69 | timeout 15m auto-merge $@ \
70 | --out-dir ${OUT_DIR:-$TMP_OUT_DIR} \
71 | $TMP_MY \
72 | $TMP_OLD \
73 | $TMP_YOUR \
74 | "$TEST_SCRIPT" \
75 | 2>&1 | tee $TMP_OUTPUT
76 |
77 | grep -q "Merge resolution found" $TMP_OUTPUT
78 | }
79 |
80 | function exit_hook (){
81 | if [ -z ${KEEP_TMP} ];then
82 | rm -rf $TMP_MY
83 | rm -rf $TMP_OLD
84 | rm -rf $TMP_YOUR
85 | rm -rf $TMP_DIR
86 | rm -rf $TMP_OUT_DIR
87 | rm -rf $TMP_OUTPUT
88 | fi
89 | }
90 | trap exit_hook EXIT SIGHUP SIGINT SIGTERM
91 |
--------------------------------------------------------------------------------
/test/bin/javascript-diff-on-gcd:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | . $(dirname $0)/common
3 |
4 | if $(which acorn >/dev/null 2>/dev/null);then
5 | NUM_DIFFS="$(ast-diff test/etc/gcd/gcd.js test/etc/gcd/gcd-fix.js|grep -c "{+")"
6 | if [ "$NUM_DIFFS" == "1" ];then
7 | echo PASS
8 | exit 0
9 | else
10 | echo FAIL
11 | exit 1
12 | fi
13 | else
14 | echo SKIP
15 | exit 0
16 | fi
17 |
--------------------------------------------------------------------------------
/test/bin/lisp-diff-on-gcd:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | . $(dirname $0)/common
3 |
4 | COUNT="$(ast-diff test/etc/gcd/gcd.lisp test/etc/gcd/gcd-fix.lisp|grep -c "DEFUN EUCLIDS-GCD")"
5 | if [ "$COUNT" == "1" ];then
6 | echo PASS
7 | exit 0
8 | else
9 | echo FAIL
10 | exit 1
11 | fi
12 |
--------------------------------------------------------------------------------
/test/bin/lisp-diff-on-gcd-raw:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | . $(dirname $0)/common
3 |
4 | OUT="$(ast-diff -r test/etc/gcd/gcd.lisp test/etc/gcd/gcd-fix.lisp)"
5 | if [ "$(echo "${OUT}"|grep -ic set)" == "$(echo "${OUT}"|grep -ic setf)" ];then
6 | echo PASS
7 | exit 0
8 | else
9 | echo FAIL
10 | exit 1
11 | fi
12 |
--------------------------------------------------------------------------------
/test/bin/lisp-diff-w-wrap-on-gcd:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | . $(dirname $0)/common
3 |
4 | # To start with lets just see if we can run without throwing an error.
5 | ast-diff --wrap test/etc/gcd/gcd.lisp test/etc/gcd/gcd-fix.lisp
6 |
--------------------------------------------------------------------------------
/test/bin/octomap-diff:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Driver for octomap diff tests
4 |
5 | # NOTE: Add the following options to ast-diff to save profiling data:
6 | # --eval "(setf *profile-flame-graph* t)" \
7 | # --profile "/tmp/ast-diff-flame.data" \
8 | #
9 | DIR=$(readlink -f $(dirname $0)/../../)
10 | export PATH=$PATH:${QUICK_LISP:-${HOME}/quicklisp}/local-projects/resolve/bin
11 |
12 | ast-diff $1 $2 \
13 | --old-flags="-I $DIR/test/etc/octomap/octomap-1.7.2/include,-I $DIR/test/etc/octomap/octomap-1.7.2/src" \
14 | --new-flags="-I $DIR/test/etc/octomap/octomap-1.8.0/include,-I $DIR/test/etc/octomap/octomap-1.8.0/src" \
15 | test/etc/octomap/octomap-1.7.2/src/test_iterators.cpp \
16 | test/etc/octomap/octomap-1.8.0/src/test_iterators.cpp
17 |
18 | exit_code=$?
19 | if [ $exit_code -eq 1 ]; then
20 | echo "PASS"
21 | exit 0
22 | else
23 | echo "FAIL - A diff should have been found in octomap"
24 | exit 1
25 | fi
26 |
--------------------------------------------------------------------------------
/test/bin/octomap-diff-count:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | NUM_DIFFS="$(test/bin/octomap-diff|grep -c "{+")"
3 | if [ "$NUM_DIFFS" == "11" ];then
4 | echo PASS
5 | exit 0
6 | else
7 | echo FAIL
8 | exit 1
9 | fi
10 |
--------------------------------------------------------------------------------
/test/bin/octomap-diff-edit-tree:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | NUM_DIFFS="$(test/bin/octomap-diff --edit-tree|grep -c "Coherence")"
3 | if [ "$NUM_DIFFS" == "24" ];then
4 | echo PASS
5 | exit 0
6 | else
7 | echo FAIL
8 | exit 1
9 | fi
10 |
--------------------------------------------------------------------------------
/test/bin/rest-ast-diff-can-return-and-serve-link:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Ensure the REST ast-diff interface is able to return JSON
4 | #
5 | . $(dirname $0)/common
6 |
7 | left=$(mktemp)
8 | right=$(mktemp)
9 | port=$(shuf -i 9000-9200 -n 1)
10 |
11 | EXIT=0
12 |
13 | function exit_hook(){
14 | rm -f $left $right;
15 | exit $EXIT; }
16 | trap exit_hook SIGHUP SIGINT SIGTERM
17 |
18 | seq 10 > $left
19 | seq 10|sed 's/6/SIX/' > $right
20 |
21 | serve-ast-diff --port ${port} --debug &
22 | server_pid=$!
23 |
24 | sleep 10
25 |
26 | response=$(curl -s \
27 | -X POST \
28 | -H "Accept: application/json" \
29 | -H "Content-Type: application/json" \
30 | http://localhost:${port}/diff \
31 | --data "{\"old-file\" : \"$left\", \"new-file\" : \"$right\", \"link\" : \"YES\"}")
32 |
33 | echo "${response}"|grep "^http"
34 | EXIT=$?
35 |
36 | if [ $EXIT == 0 ];then
37 | curl ${response}|grep "text/json"
38 | EXIT=$?
39 | fi
40 |
41 | kill -SIGINT ${server_pid}
42 | wait ${server_pid}
43 | exit_hook
44 |
--------------------------------------------------------------------------------
/test/bin/rest-ast-diff-returns-json:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Ensure the REST ast-diff interface is able to return JSON
4 | #
5 | . $(dirname $0)/common
6 |
7 | left=$(mktemp)
8 | right=$(mktemp)
9 | port=$(shuf -i 9000-9200 -n 1)
10 |
11 | EXIT=0
12 |
13 | function exit_hook(){
14 | rm -f $left $right;
15 | exit $EXIT; }
16 | trap exit_hook SIGHUP SIGINT SIGTERM
17 |
18 | seq 10 > $left
19 | seq 10|sed 's/6/SIX/' > $right
20 |
21 | serve-ast-diff --port ${port} --debug &
22 | server_pid=$!
23 |
24 | sleep 10
25 |
26 | response=$(curl -s \
27 | -X POST \
28 | -H "Accept: application/json" \
29 | -H "Content-Type: application/json" \
30 | http://localhost:${port}/diff \
31 | --data "{\"old-file\" : \"$left\", \"new-file\" : \"$right\"}")
32 |
33 | echo "${response}"|grep "^\[.*\]$"
34 | EXIT=$?
35 |
36 | kill -SIGINT ${server_pid}
37 | wait ${server_pid}
38 | exit_hook
39 |
--------------------------------------------------------------------------------
/test/bin/rest-ast-diff-takes-full-strings:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Ensure the REST ast-diff interface takes full strings
4 | #
5 | . $(dirname $0)/common
6 |
7 | port=$(shuf -i 9000-9200 -n 1)
8 | EXIT=0
9 |
10 | serve-ast-diff --port ${port} --debug &
11 | server_pid=$!
12 | sleep 10
13 |
14 | function exit_hook(){
15 | kill -SIGINT ${server_pid};
16 | wait ${server_pid};
17 | exit $EXIT; }
18 | trap exit_hook SIGHUP SIGINT SIGTERM
19 |
20 | rest-ast-diff -p ${port} -a text/plain -l javascript \
21 | test/etc/javascript/abacus/abacus-{orig,borders}.js \
22 | |grep -i "\({+console.log\|\+}\)"
23 | EXIT=$?
24 | exit_hook
25 |
--------------------------------------------------------------------------------
/test/etc/binary_search.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "read_words.h"
5 |
6 | int binary_search(const char *needle, char **haystack, int start, int end) {
7 | int mid;
8 | int rc;
9 | if (start == end) {
10 | return -1;
11 | }
12 |
13 | mid = (start + end) / 2;
14 | rc = strcmp(needle, haystack[mid]);
15 | if (rc < 0) {
16 | return binary_search(needle, haystack, start, mid);
17 | } else if (rc > 0) {
18 | return binary_search(needle, haystack, mid + 1, end);
19 | }
20 |
21 | return mid;
22 | }
23 |
24 | int main(int argc, char** argv) {
25 | if(argc != 6) {
26 | printf("USAGE: binary_search [STRING] [NUM_WORDS] [START] ");
27 | printf("[END] [FILE]\n");
28 | return 1;
29 | }
30 | else {
31 | char *needle = argv[1];
32 | unsigned int haystack_size = atoi(argv[2]);
33 | unsigned int start = atoi(argv[3]);
34 | unsigned int end = atoi(argv[4]);
35 | char *filename = argv[5];
36 | char **haystack = malloc(haystack_size * sizeof(*haystack));
37 | if(haystack) {
38 | FILE *fp = fopen(filename, "r");
39 | unsigned int index = -2;
40 | size_t i;
41 | for(i = 0; i b) a = a - b;
5 | else b = b - a;
6 |
7 | return a;
8 | }
9 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-1/gcd.h:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b);
2 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-1/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "gcd.h"
5 |
6 | int main(int argc, char *argv[]) {
7 | int a = atoi(argv[1]);
8 | int b = atoi(argv[2]);
9 |
10 | printf("gcd=%d\n", gcd(a, b));
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-2/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-2/gcd.c:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b) {
2 | if (a == 0) {
3 | return b;
4 | } else {
5 | while (b != 0)
6 | if (a > b) a = a - b;
7 | else b = b - a;
8 | }
9 |
10 | return a;
11 | }
12 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-2/gcd.h:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b);
2 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-2/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "gcd.h"
5 |
6 | int main(int argc, char *argv[]) {
7 | int a = atoi(argv[1]);
8 | int b = atoi(argv[2]);
9 |
10 | printf("%d\n", gcd(a, b));
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-3/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-3/gcd.c:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b) {
2 | if (a == 0) return a;
3 | while (b != 0)
4 | if (a > b) a = a - b;
5 | else b = b - a;
6 |
7 | return a;
8 | }
9 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-3/gcd.h:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b);
2 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/gcd-3/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "gcd.h"
5 |
6 | int main(int argc, char *argv[]) {
7 | int a = atoi(argv[1]);
8 | int b = atoi(argv[2]);
9 |
10 | printf("%d\n", gcd(a, b));
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-auto-merge/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # $1 = EXE
3 | # $2 = test case number
4 | # exit 0 = success
5 |
6 | # prevent tests from hanging
7 | ulimit -t 1
8 |
9 | # prevent generation of core files
10 | ulimit -c 0
11 |
12 | test_equal(){ if [ "$1" == "$2" ];then exit 0;else exit 1;fi }
13 |
14 | case $2 in
15 | # positive tests
16 | 0) test_equal "$($1 1071 1029)" "21" ;;
17 | 1) test_equal "$($1 555 666)" "111" ;;
18 | 2) test_equal "$($1 678 987)" "3" ;;
19 | 3) test_equal "$($1 8767 653)" "1" ;;
20 | 4) test_equal "$($1 16777216 512)" "512" ;;
21 | 5) test_equal "$($1 16 4)" "4" ;;
22 | 6) test_equal "$($1 315 831)" "3" ;;
23 | 7) test_equal "$($1 513332 91583315)" "1" ;;
24 | 8) test_equal "$($1 112 135)" "1" ;;
25 | 9) test_equal "$($1 310 55)" "5" ;;
26 | 10) test_equal "$($1 55 0)" "55" ;;
27 | # negative test
28 | 11) test_equal "$($1 0 55)" "55" ;;
29 | esac
30 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-1/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-1/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int gcd(int a, int b) {
5 | if (a == 0) return b;
6 | while (b != 0)
7 | if (a > b) a = a - b;
8 | else b = b - a;
9 |
10 | return a;
11 | }
12 |
13 | int main(int argc, char *argv[]) {
14 | int a = atoi(argv[1]);
15 | int b = atoi(argv[2]);
16 |
17 | printf("gcd=%d\n", gcd(a, b));
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-2/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-2/gcd.c:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b) {
2 | if (a == 0) {
3 | return b;
4 | } else {
5 | while (b != 0)
6 | if (a > b) a = a - b;
7 | else b = b - a;
8 | }
9 |
10 | return a;
11 | }
12 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-2/gcd.h:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b);
2 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-2/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "gcd.h"
5 |
6 | int main(int argc, char *argv[]) {
7 | int a = atoi(argv[1]);
8 | int b = atoi(argv[2]);
9 |
10 | printf("%d\n", gcd(a, b));
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-3/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/gcd-3/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int gcd(int a, int b) {
5 | if (a == 0) return a;
6 | while (b != 0)
7 | if (a > b) a = a - b;
8 | else b = b - a;
9 |
10 | return a;
11 | }
12 |
13 | int main(int argc, char *argv[]) {
14 | int a = atoi(argv[1]);
15 | int b = atoi(argv[2]);
16 |
17 | printf("%d\n", gcd(a, b));
18 | return 0;
19 | }
20 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-delete-file-auto-merge/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # $1 = EXE
3 | # $2 = test case number
4 | # exit 0 = success
5 |
6 | # prevent tests from hanging
7 | ulimit -t 1
8 |
9 | # prevent generation of core files
10 | ulimit -c 0
11 |
12 | test_equal(){ if [ "$1" == "$2" ];then exit 0;else exit 1;fi }
13 |
14 | case $2 in
15 | # positive tests
16 | 0) test_equal "$($1 1071 1029)" "21" ;;
17 | 1) test_equal "$($1 555 666)" "111" ;;
18 | 2) test_equal "$($1 678 987)" "3" ;;
19 | 3) test_equal "$($1 8767 653)" "1" ;;
20 | 4) test_equal "$($1 16777216 512)" "512" ;;
21 | 5) test_equal "$($1 16 4)" "4" ;;
22 | 6) test_equal "$($1 315 831)" "3" ;;
23 | 7) test_equal "$($1 513332 91583315)" "1" ;;
24 | 8) test_equal "$($1 112 135)" "1" ;;
25 | 9) test_equal "$($1 310 55)" "5" ;;
26 | 10) test_equal "$($1 55 0)" "55" ;;
27 | # negative test
28 | 11) test_equal "$($1 0 55)" "55" ;;
29 | esac
30 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-1/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-1/gcd1.c:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b) {
2 | if (a == 0) return b;
3 | while (b != 0)
4 | if (a > b) a = a - b;
5 | else b = b - a;
6 |
7 | return a;
8 | }
9 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-1/gcd1.h:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b);
2 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-1/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "gcd1.h"
5 |
6 | int main(int argc, char *argv[]) {
7 | int a = atoi(argv[1]);
8 | int b = atoi(argv[2]);
9 |
10 | printf("gcd=%d\n", gcd(a, b));
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-2/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-2/gcd.c:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b) {
2 | if (a == 0) {
3 | return b;
4 | } else {
5 | while (b != 0)
6 | if (a > b) a = a - b;
7 | else b = b - a;
8 | }
9 |
10 | return a;
11 | }
12 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-2/gcd.h:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b);
2 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-2/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "gcd.h"
5 |
6 | int main(int argc, char *argv[]) {
7 | int a = atoi(argv[1]);
8 | int b = atoi(argv[2]);
9 |
10 | printf("%d\n", gcd(a, b));
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-3/Makefile:
--------------------------------------------------------------------------------
1 | TARGET = gcd
2 |
3 | .PHONY: default all clean
4 |
5 | default: $(TARGET)
6 | all: default
7 |
8 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
9 | HEADERS = $(wildcard *.h)
10 |
11 | %.o: %.c $(HEADERS)
12 | $(CC) $(CFLAGS) -c $< -o $@
13 |
14 | .PRECIOUS: $(TARGET) $(OBJECTS)
15 |
16 | $(TARGET): $(OBJECTS)
17 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@
18 |
19 | clean:
20 | -rm -f *.o
21 | -rm -f $(TARGET)
22 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-3/gcd.c:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b) {
2 | if (a == 0) return a;
3 | while (b != 0)
4 | if (a > b) a = a - b;
5 | else b = b - a;
6 |
7 | return a;
8 | }
9 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-3/gcd.h:
--------------------------------------------------------------------------------
1 | int gcd(int a, int b);
2 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/gcd-3/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "gcd.h"
5 |
6 | int main(int argc, char *argv[]) {
7 | int a = atoi(argv[1]);
8 | int b = atoi(argv[2]);
9 |
10 | printf("%d\n", gcd(a, b));
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/gcd-project-insert-file-auto-merge/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # $1 = EXE
3 | # $2 = test case number
4 | # exit 0 = success
5 |
6 | # prevent tests from hanging
7 | ulimit -t 1
8 |
9 | # prevent generation of core files
10 | ulimit -c 0
11 |
12 | test_equal(){ if [ "$1" == "$2" ];then exit 0;else exit 1;fi }
13 |
14 | case $2 in
15 | # positive tests
16 | 0) test_equal "$($1 1071 1029)" "21" ;;
17 | 1) test_equal "$($1 555 666)" "111" ;;
18 | 2) test_equal "$($1 678 987)" "3" ;;
19 | 3) test_equal "$($1 8767 653)" "1" ;;
20 | 4) test_equal "$($1 16777216 512)" "512" ;;
21 | 5) test_equal "$($1 16 4)" "4" ;;
22 | 6) test_equal "$($1 315 831)" "3" ;;
23 | 7) test_equal "$($1 513332 91583315)" "1" ;;
24 | 8) test_equal "$($1 112 135)" "1" ;;
25 | 9) test_equal "$($1 310 55)" "5" ;;
26 | 10) test_equal "$($1 55 0)" "55" ;;
27 | # negative test
28 | 11) test_equal "$($1 0 55)" "55" ;;
29 | esac
30 |
--------------------------------------------------------------------------------
/test/etc/gcd-single-file-auto-merge/gcd-1.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a,b,c;
6 | double r1, r2;
7 | a = atoi(argv[1]);
8 | b = atoi(argv[2]);
9 |
10 | if (a == 0) printf("gcd=%g\n", b);
11 | while (b != 0)
12 | if (a > b) a = a - b;
13 | else b = b - a;
14 |
15 | printf("gcd=%g\n", a);
16 |
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/test/etc/gcd-single-file-auto-merge/gcd-2.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a,b,c;
6 | double r1, r2;
7 | a = atoi(argv[1]);
8 | b = atoi(argv[2]);
9 |
10 | if (a == 0) {
11 | printf("%g\n", b);
12 | } else {
13 | while (b != 0)
14 | if (a > b) a = a - b;
15 | else b = b - a;
16 | }
17 | printf("%g\n", a);
18 |
19 | return 0;
20 | }
21 |
--------------------------------------------------------------------------------
/test/etc/gcd-single-file-auto-merge/gcd-3.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a,b,c;
6 | double r1, r2;
7 | a = atoi(argv[1]);
8 | b = atoi(argv[2]);
9 |
10 | if (a == 0) printf("%g\n", b);
11 | while (b != 0)
12 | if (a > b) a = a - b;
13 | else b = b - a;
14 |
15 | printf("%g\n", a);
16 |
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/test/etc/gcd-single-file-auto-merge/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # $1 = EXE
3 | # $2 = test case number
4 | # exit 0 = success
5 |
6 | # prevent tests from hanging
7 | ulimit -t 1
8 |
9 | # prevent generation of core files
10 | ulimit -c 0
11 |
12 | test_equal(){ if [ "$1" == "$2" ];then exit 0;else exit 1;fi }
13 |
14 | case $2 in
15 | # positive tests
16 | 0) test_equal "$($1 1071 1029)" "21" ;;
17 | 1) test_equal "$($1 555 666)" "111" ;;
18 | 2) test_equal "$($1 678 987)" "3" ;;
19 | 3) test_equal "$($1 8767 653)" "1" ;;
20 | 4) test_equal "$($1 16777216 512)" "512" ;;
21 | 5) test_equal "$($1 16 4)" "4" ;;
22 | 6) test_equal "$($1 315 831)" "3" ;;
23 | 7) test_equal "$($1 513332 91583315)" "1" ;;
24 | 8) test_equal "$($1 112 135)" "1" ;;
25 | 9) test_equal "$($1 310 55)" "5" ;;
26 | 10) test_equal "$($1 55 0)" "55" ;;
27 | # negative test
28 | 11) test_equal "$($1 0 55)" "55" ;;
29 | esac
30 |
--------------------------------------------------------------------------------
/test/etc/gcd/.gitignore:
--------------------------------------------------------------------------------
1 | a.out
2 | gcd
3 | gcd.s
4 | gcd.ll
5 | fixed
6 | fixed.s
7 | *.store
8 | lisp-runner
9 | seed
10 | *.class
11 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd-fix.js:
--------------------------------------------------------------------------------
1 | function gcd(a, b) {
2 | if (a === 0){
3 | util.format('%d\n', b);
4 | } else {
5 | while (b != 0) {
6 | if (a > b) {
7 | a = a - b;
8 | } else {
9 | b = b - a;
10 | }
11 | }
12 | util.format("%d\n", a);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd-fix.lisp:
--------------------------------------------------------------------------------
1 | ;; Buggy implementation of Euclid's GCD Algorithm
2 | (DEFUN EUCLIDS-GCD (A B)
3 | (IF (= A 0)
4 | B
5 | (DO ()
6 | ((= B 0) A)
7 | (IF (> A B)
8 | (SETF A (- A B))
9 | (SETF B (- B A))))))
10 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd-prose.js:
--------------------------------------------------------------------------------
1 | function gcd(a, b) {
2 | if (a === 0){
3 | util.format('gcd=%d\n', b);
4 | }
5 | while (b != 0) {
6 | if (a > b) {
7 | a = a - b;
8 | } else {
9 | b = b - a;
10 | }
11 | }
12 | util.format("gcd=%d\n", a);
13 | }
14 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd-wo-curlies-fix.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a,b,c;
6 | double r1, r2;
7 | a = atoi(argv[1]);
8 | b = atoi(argv[2]);
9 |
10 | if (a == 0) {
11 | printf("%g\n", b);
12 | } else {
13 | while (b != 0)
14 | if (a > b) a = a - b;
15 | else b = b - a;
16 | }
17 | printf("%g\n", a);
18 |
19 | return 0;
20 | }
21 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd-wo-curlies-prose.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a,b,c;
6 | double r1, r2;
7 | a = atoi(argv[1]);
8 | b = atoi(argv[2]);
9 |
10 | if (a == 0) printf("gcd=%g\n", b);
11 | while (b != 0)
12 | if (a > b) a = a - b;
13 | else b = b - a;
14 |
15 | printf("gcd=%g\n", a);
16 |
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd-wo-curlies.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a,b,c;
6 | double r1, r2;
7 | a = atoi(argv[1]);
8 | b = atoi(argv[2]);
9 |
10 | if (a == 0) printf("%g\n", b);
11 | while (b != 0)
12 | if (a > b) a = a - b;
13 | else b = b - a;
14 |
15 | printf("%g\n", a);
16 |
17 | return 0;
18 | }
19 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a;
6 | double b;
7 | double c;
8 | double r1;
9 | double r2;
10 |
11 | a = atoi(argv[1]);
12 | b = atoi(argv[2]);
13 |
14 | if (a == 0) { printf("%g\n", b); }
15 | else { }
16 | {
17 | while (b != 0) {
18 | if (a > b) {
19 | a = a - b;
20 | } else {
21 | b = b - a;
22 | }
23 | }
24 | printf("%g\n", a);
25 | }
26 |
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd.js:
--------------------------------------------------------------------------------
1 | function gcd(a, b) {
2 | if (a === 0){
3 | util.format('%d\n', b);
4 | }
5 | while (b != 0) {
6 | if (a > b) {
7 | a = a - b;
8 | } else {
9 | b = b - a;
10 | }
11 | }
12 | util.format("%d\n", a);
13 | }
14 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd.lisp:
--------------------------------------------------------------------------------
1 | ;; Buggy implementation of Euclid's GCD Algorithm
2 | (DEFUN EUCLIDS-GCD (A B)
3 | (IF (= A 0)
4 | B)
5 | (DO ()
6 | ((= B 0) A)
7 | (IF (> A B)
8 | (SETF A (- A B))
9 | (SETF B (- B A)))))
10 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd.s.att:
--------------------------------------------------------------------------------
1 | .file "gcd.c"
2 | .section .rodata
3 | .LC1:
4 | .string "%g\n"
5 | .text
6 | .globl main
7 | .type main, @function
8 | main:
9 | .LFB2:
10 | .cfi_startproc
11 | pushq %rbp
12 | .cfi_def_cfa_offset 16
13 | .cfi_offset 6, -16
14 | movq %rsp, %rbp
15 | .cfi_def_cfa_register 6
16 | subq $48, %rsp
17 | movl %edi, -20(%rbp)
18 | movq %rsi, -32(%rbp)
19 | movq -32(%rbp), %rax
20 | addq $8, %rax
21 | movq (%rax), %rax
22 | movq %rax, %rdi
23 | call atoi
24 | pxor %xmm0, %xmm0
25 | cvtsi2sd %eax, %xmm0
26 | movsd %xmm0, -16(%rbp)
27 | movq -32(%rbp), %rax
28 | addq $16, %rax
29 | movq (%rax), %rax
30 | movq %rax, %rdi
31 | call atoi
32 | pxor %xmm0, %xmm0
33 | cvtsi2sd %eax, %xmm0
34 | movsd %xmm0, -8(%rbp)
35 | pxor %xmm0, %xmm0
36 | ucomisd -16(%rbp), %xmm0
37 | jp .L4
38 | pxor %xmm0, %xmm0
39 | ucomisd -16(%rbp), %xmm0
40 | jne .L2
41 | movq -8(%rbp), %rax
42 | movq %rax, -40(%rbp)
43 | movsd -40(%rbp), %xmm0
44 | movl $.LC1, %edi
45 | movl $1, %eax
46 | call printf
47 | .L2:
48 | jmp .L4
49 | .L7:
50 | movsd -16(%rbp), %xmm0
51 | ucomisd -8(%rbp), %xmm0
52 | jbe .L11
53 | movsd -16(%rbp), %xmm0
54 | subsd -8(%rbp), %xmm0
55 | movsd %xmm0, -16(%rbp)
56 | jmp .L4
57 | .L11:
58 | movsd -8(%rbp), %xmm0
59 | subsd -16(%rbp), %xmm0
60 | movsd %xmm0, -8(%rbp)
61 | .L4:
62 | pxor %xmm0, %xmm0
63 | ucomisd -8(%rbp), %xmm0
64 | jp .L7
65 | pxor %xmm0, %xmm0
66 | ucomisd -8(%rbp), %xmm0
67 | jne .L7
68 | movq -16(%rbp), %rax
69 | movq %rax, -40(%rbp)
70 | movsd -40(%rbp), %xmm0
71 | movl $.LC1, %edi
72 | movl $1, %eax
73 | call printf
74 | movl $0, %eax
75 | leave
76 | .cfi_def_cfa 7, 8
77 | ret
78 | .cfi_endproc
79 | .LFE2:
80 | .size main, .-main
81 | .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609"
82 | .section .note.GNU-stack,"",@progbits
83 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd.s.intel:
--------------------------------------------------------------------------------
1 | .file "gcd.c"
2 | .intel_syntax noprefix
3 | .section .rodata
4 | .LC1:
5 | .string "%g\n"
6 | .text
7 | .globl main
8 | .type main, @function
9 | main:
10 | .LFB2:
11 | .cfi_startproc
12 | push rbp
13 | .cfi_def_cfa_offset 16
14 | .cfi_offset 6, -16
15 | mov rbp, rsp
16 | .cfi_def_cfa_register 6
17 | sub rsp, 48
18 | mov DWORD PTR [rbp-20], edi
19 | mov QWORD PTR [rbp-32], rsi
20 | mov rax, QWORD PTR [rbp-32]
21 | add rax, 8
22 | mov rax, QWORD PTR [rax]
23 | mov rdi, rax
24 | call atoi
25 | pxor xmm0, xmm0
26 | cvtsi2sd xmm0, eax
27 | movsd QWORD PTR [rbp-16], xmm0
28 | mov rax, QWORD PTR [rbp-32]
29 | add rax, 16
30 | mov rax, QWORD PTR [rax]
31 | mov rdi, rax
32 | call atoi
33 | pxor xmm0, xmm0
34 | cvtsi2sd xmm0, eax
35 | movsd QWORD PTR [rbp-8], xmm0
36 | pxor xmm0, xmm0
37 | ucomisd xmm0, QWORD PTR [rbp-16]
38 | jp .L4
39 | pxor xmm0, xmm0
40 | ucomisd xmm0, QWORD PTR [rbp-16]
41 | jne .L2
42 | mov rax, QWORD PTR [rbp-8]
43 | mov QWORD PTR [rbp-40], rax
44 | movsd xmm0, QWORD PTR [rbp-40]
45 | mov edi, OFFSET FLAT:.LC1
46 | mov eax, 1
47 | call printf
48 | .L2:
49 | jmp .L4
50 | .L7:
51 | movsd xmm0, QWORD PTR [rbp-16]
52 | ucomisd xmm0, QWORD PTR [rbp-8]
53 | jbe .L11
54 | movsd xmm0, QWORD PTR [rbp-16]
55 | subsd xmm0, QWORD PTR [rbp-8]
56 | movsd QWORD PTR [rbp-16], xmm0
57 | jmp .L4
58 | .L11:
59 | movsd xmm0, QWORD PTR [rbp-8]
60 | subsd xmm0, QWORD PTR [rbp-16]
61 | movsd QWORD PTR [rbp-8], xmm0
62 | .L4:
63 | pxor xmm0, xmm0
64 | ucomisd xmm0, QWORD PTR [rbp-8]
65 | jp .L7
66 | pxor xmm0, xmm0
67 | ucomisd xmm0, QWORD PTR [rbp-8]
68 | jne .L7
69 | mov rax, QWORD PTR [rbp-16]
70 | mov QWORD PTR [rbp-40], rax
71 | movsd xmm0, QWORD PTR [rbp-40]
72 | mov edi, OFFSET FLAT:.LC1
73 | mov eax, 1
74 | call printf
75 | mov eax, 0
76 | leave
77 | .cfi_def_cfa 7, 8
78 | ret
79 | .cfi_endproc
80 | .LFE2:
81 | .size main, .-main
82 | .ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609"
83 | .section .note.GNU-stack,"",@progbits
84 |
--------------------------------------------------------------------------------
/test/etc/gcd/gcd2.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a;
6 | double b;
7 | double c;
8 | double r1;
9 | double r2;
10 |
11 | b = atoi(argv[2]);
12 | a = atoi(argv[1]);
13 |
14 | if (a == 0) { printf("%g\n", b); }
15 | else { }
16 | {
17 | while (b != 0) {
18 | if (a > b) {
19 | a = a - b;
20 | } else {
21 | b = b - a;
22 | }
23 | }
24 | printf("%g\n", a);
25 | }
26 |
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/test/etc/gcd/limit.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | int main(int argc, char *argv[]) {
7 |
8 | // resource/time limits
9 | struct rlimit limit;
10 | limit.rlim_cur = 1; limit.rlim_max = 1;
11 | setrlimit(RLIMIT_CPU, &limit); // cpu seconds
12 | limit.rlim_cur = 124000; limit.rlim_max = 124000;
13 | setrlimit(RLIMIT_NPROC, &limit); // number of spawned processes
14 | limit.rlim_cur = 124000; limit.rlim_max = 124000;
15 | setrlimit(RLIMIT_NOFILE, &limit); // number of open files
16 | limit.rlim_cur = 124000; limit.rlim_max = 124000;
17 | setrlimit(RLIMIT_FSIZE, &limit); // max file size (bytes)
18 | setrlimit(RLIMIT_MEMLOCK, &limit); // max memory locked into RAM (bytes)
19 | setrlimit(RLIMIT_STACK, &limit); // max stack size (bytes)
20 | alarm(1); // wall clock seconds
21 |
22 | // run
23 | return execvp(argv[1], &argv[1]);
24 | }
25 |
--------------------------------------------------------------------------------
/test/etc/gcd/repair-asm.lisp:
--------------------------------------------------------------------------------
1 | ;; repair using software evolution
2 | (require :software-evolution-library/lisp)
3 | (in-package :software-evolution-library/lisp)
4 | (in-readtable :curry-compose-reader-macros)
5 |
6 | (load #P"repair.lisp")
7 |
8 | (defvar *asm*
9 | (progn
10 | (unless (probe-file "gcd.s")
11 | (shell "gcc -S gcd.c"))
12 | (from-file (make-instance 'asm) "gcd.s")))
13 |
14 | ;; Add the good and bad path information to gcd
15 | ;; (apply-path original :neg (samples-from-oprofile-file "sample.neg"))
16 | ;; (apply-path original :pos (samples-from-oprofile-file "sample.pos"))
17 |
18 | #+run
19 | (sb-thread:make-thread
20 | (lambda ()
21 | (setf (fitness *asm*) (test-suite *asm*))
22 | (setf *population* (loop :for i :below 100 :collect (copy *asm*)))
23 | (let ((*max-population-size* 100)
24 | (*target-fitness-p* (lambda (obj)
25 | (or (= 12 (fitness obj))
26 | (funcall *fitness-predicate* (fitness obj) 12)))))
27 | (store (evolve #'test-suite ) "results-asm.store"))))
28 |
--------------------------------------------------------------------------------
/test/etc/gcd/repair-ast.lisp:
--------------------------------------------------------------------------------
1 | ;; repair using software evolution
2 | (require :software-evolution-library)
3 | (load #P"test/gcd/repair.lisp")
4 | (in-package :repair)
5 | (in-readtable :curry-compose-reader-macros)
6 |
7 | (defvar *path* "test/gcd/gcd.c")
8 | (defvar *clang* (from-file (make-instance 'clang) *path*))
9 | (defvar *cil* (from-file (make-instance 'cil) *path*))
10 |
11 | (defun brute-force-ast (ast)
12 | "Perform a brute force search for the repair to gcd.c.
13 | Prints updates on the progress of the search, saves the discovered
14 | repair to \"results.store\", and prints errors if known repairs are
15 | not found."
16 | (assert (or (eq (type-of ast) 'cil)
17 | (eq (type-of ast) 'clang)) (ast)
18 | "AST should be either a cil or clang object")
19 | (let ((num (size ast)))
20 | (store
21 | (block repair
22 | (flet ((mut (op)
23 | (let* ((it (copy ast)))
24 | (apply-mutation it op)
25 | (setf (fitness it) (test-suite it))
26 | (if (= 11 (fitness it))
27 | (progn (format t "repair found!~%")
28 | (return-from repair it))
29 | (format t " ~2d ~a~%" (fitness it) op)))))
30 | ;; insert
31 | (loop :for left :below num :do
32 | (loop :for right :below num :do
33 | (mut (list :insert left right))))
34 | (when (eq (type-of ast) 'cil)
35 | (error "should have found it by now (:INSERT 0 9)"))
36 | ;; delete
37 | (loop :for id :below num :do
38 | (mut (list :cut id)))
39 | (when (eq (type-of ast) 'clang)
40 | (error "should have found it by now (:CUT 42)"))
41 | ;; swap
42 | (loop :for left :below num :do
43 | (loop :for right :below num :do
44 | (mut (list :swap left right))))))
45 | "results.store")))
46 |
47 | #+(or )
48 | ((lambda (ast)
49 | (let ((*population* (loop :for i :below 100 :collect (copy ast)))
50 | (*max-population-size* 100))
51 | (store (evolve #'test-suite :max-fit 12) "results-ast.store")))
52 | *cil*)
53 |
--------------------------------------------------------------------------------
/test/etc/gcd/repair-gcd.lisp:
--------------------------------------------------------------------------------
1 | ;; repair using software evolution
2 | (load #P"repair.lisp")
3 | (in-package :repair)
4 | (in-readtable :curry-compose-reader-macros)
5 |
6 | (defvar *clang* (from-file (make-instance 'clang) "gcd.c"))
7 | (defvar *cil* (from-file (make-instance 'cil) "gcd.c"))
8 | (defvar *llvm* (from-file (make-instance 'llvm) "gcd.ll"))
9 |
10 | (defun brute-force-ast (ast)
11 | (assert (or (eq (type-of ast) 'cil)
12 | (eq (type-of ast) 'clang)
13 | (eq (type-of ast) 'llvm)) (ast)
14 | "AST should be either a cil or clang object")
15 | (let ((fitness (test-suite ast)))
16 | (assert (= 10 fitness) (ast)
17 | "AST should pass 10/11 test cases but instead passes ~a/11"
18 | fitness))
19 | (let ((num (size ast)))
20 | (store
21 | (block repair
22 | (flet ((mut (op)
23 | (let ((new (copy ast)))
24 | (apply-mutation new op)
25 | (when (= 11 (test-suite new))
26 | (format t "repair found!~%")
27 | (return-from repair new)))))
28 | ;; replace
29 | (when (eq (type-of ast) 'llvm)
30 | (loop :for left :below num :do
31 | (loop :for right :below num :do
32 | (format t "replace ~d ~d~%" left right)
33 | (mut (list :replace left right)))))
34 | ;; delete
35 | (loop :for id :below num :do
36 | (mut (list :cut id)))
37 | (when (eq (type-of ast) 'clang)
38 | (error 'brute-force "should have found it by now (:CUT 42)"))
39 | ;; insert
40 | (loop :for left :below num :do
41 | (loop :for right :below num :do
42 | (mut (list :insert left right))))
43 | (when (eq (type-of ast) 'cil)
44 | (error 'brute-force "should have found it by now (:INSERT 0 9)"))
45 | ;; swap
46 | (loop :for left :below num :do
47 | (loop :for right :below num :do
48 | (mut (list :swap left right))))))
49 | "results.store")))
50 |
51 | #+run
52 | ((lambda (ast)
53 | (let ((*population* (loop :for i :below 100 :collect (copy ast)))
54 | (*max-population-size* 100))
55 | (store (evolve #'test-suite :max-fit 12) "results-ast.store")))
56 | *cil*)
57 |
--------------------------------------------------------------------------------
/test/etc/gcd/repair-lisp.lisp:
--------------------------------------------------------------------------------
1 | ;; repair using software evolution
2 | (require :software-evolution-library/lisp)
3 | (in-package :software-evolution-library/lisp)
4 | (in-readtable :curry-compose-reader-macros)
5 |
6 | ;; ensure the runner is build and ready
7 | (unless (probe-file "lisp-runner")
8 | (error "Need to build the lisp-runner (make test/gcd/lisp-runner)."))
9 |
10 | ;; set required global parameters
11 | (setq *pos-test-num* 10)
12 | (setq *neg-test-num* 1)
13 | (setq *test-script* "test-lisp.sh")
14 | (setq *max-population-size* 100)
15 | (defvar *gcd* (lisp-from-file "gcd.lisp"))
16 |
17 | ;; build up a starting population
18 | (dotimes (n 8) (push *gcd* *population*))
19 |
20 | ;; evolve a repair
21 | (defvar *repair* (repair :max-evals 1000 :max-fit 11))
22 |
23 | ;; conditionally save the repair
24 | (let ((fixed-program-path "fixed.lisp"))
25 | (if *repair*
26 | (progn (format t "~&Repair found, saving to ~a~%" fixed-program-path)
27 | (lisp-to-file *repair* fixed-program-path))
28 | (format t "~&No repair found.~%")))
29 |
--------------------------------------------------------------------------------
/test/etc/gcd/repair.lisp:
--------------------------------------------------------------------------------
1 | ;; repair using software evolution
2 | (mapcar #'require '(:software-evolution-library))
3 | (defpackage :repair
4 | (:use :gt/full
5 | :software-evolution-library))
6 | (in-package :repair)
7 | (in-readtable :curry-compose-reader-macros)
8 |
9 | ;; reproducibility
10 | (let ((seed-path "seed"))
11 | (if (probe-file seed-path)
12 | (setf *random-state* (with-open-file (in seed-path) (read in)))
13 | (progn
14 | (setf *random-state* (make-random-state t))
15 | (with-open-file (out seed-path :direction :output)
16 | (write *random-state* :stream out)))))
17 |
18 | (defvar *test* "./test/gcd/test.sh")
19 |
20 | (defun test-suite (ast)
21 | (with-temporary-file (:pathname bin)
22 | (if (zerop (second (multiple-value-list (phenome ast :bin bin))))
23 | (count t (loop :for num :upto 10 :collect
24 | (multiple-value-bind (output err-output exit)
25 | (shell "~a ~a ~a" *test* bin num)
26 | (declare (ignorable output err-output))
27 | (zerop exit))))
28 | 0)))
29 |
--------------------------------------------------------------------------------
/test/etc/gcd/simple/gcd.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | double a,b,c;
6 | double r1, r2;
7 | a = atoi(argv[1]);
8 | b = atoi(argv[2]);
9 |
10 | if (a == 0) { printf("%g\n", b); }
11 | while (b != 0) {
12 | if (a > b) {
13 | a = a - b;
14 | } else {
15 | b = b - a;
16 | }
17 | }
18 | printf("%g\n", a);
19 |
20 | return 0;
21 | }
22 |
--------------------------------------------------------------------------------
/test/etc/gcd/test-lisp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # $1 = EXE
3 | # $2 = test name
4 | # exit 0 = success
5 | ulimit -t 1
6 | basedir=$(dirname $0)
7 | prog=$1
8 | test_equal(){
9 | result=$($basedir../../bin/lisp-runner $prog "(euclids-gcd $1 $2)")
10 | if [ "$result" == "$3" ];then exit 0;else exit 1;fi
11 | }
12 | case $2 in
13 | p1) test_equal 1071 1029 21 ;;
14 | p2) test_equal 555 666 111 ;;
15 | p3) test_equal 678 987 3 ;;
16 | p4) test_equal 8767 653 1 ;;
17 | p5) test_equal 16777216 512 512 ;;
18 | p6) test_equal 16 4 4 ;;
19 | p7) test_equal 315 831 3 ;;
20 | p8) test_equal 513332 91583315 1 ;;
21 | p9) test_equal 112 135 1 ;;
22 | p10) test_equal 310 55 5 ;;
23 | n1) test_equal 0 55 55 ;;
24 | esac
25 |
--------------------------------------------------------------------------------
/test/etc/gcd/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # $1 = EXE
3 | # $2 = test case number
4 | # exit 0 = success
5 |
6 | # prevent tests from hanging
7 | ulimit -t 1
8 |
9 | # prevent generation of core files
10 | ulimit -c 0
11 |
12 | test_equal(){ if [ "$1" == "$2" ];then exit 0;else exit 1;fi }
13 |
14 | case $2 in
15 | # positive tests
16 | 0) test_equal "$($1 1071 1029)" "21" ;;
17 | 1) test_equal "$($1 555 666)" "111" ;;
18 | 2) test_equal "$($1 678 987)" "3" ;;
19 | 3) test_equal "$($1 8767 653)" "1" ;;
20 | 4) test_equal "$($1 16777216 512)" "512" ;;
21 | 5) test_equal "$($1 16 4)" "4" ;;
22 | 6) test_equal "$($1 315 831)" "3" ;;
23 | 7) test_equal "$($1 513332 91583315)" "1" ;;
24 | 8) test_equal "$($1 112 135)" "1" ;;
25 | 9) test_equal "$($1 310 55)" "5" ;;
26 | 10) test_equal "$($1 55 0)" "55" ;;
27 | # negative test
28 | 11) test_equal "$($1 0 55)" "55" ;;
29 | esac
30 |
--------------------------------------------------------------------------------
/test/etc/javascript/abacus/.gitignore:
--------------------------------------------------------------------------------
1 | merged-*
2 | conflict-*
3 |
--------------------------------------------------------------------------------
/test/etc/javascript/abacus/abacus-animate.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | const path = require('path')
3 |
4 | function line(number){
5 | switch(number){
6 | case "0": console.log('.......XXXXXXXXX'); break;
7 | case "1": console.log('X.......XXXXXXXX'); break;
8 | case "2": console.log('XX.......XXXXXXX'); break;
9 | case "3": console.log('XXX.......XXXXXX'); break;
10 | case "4": console.log('XXXX.......XXXXX'); break;
11 | case "5": console.log('XXXXX.......XXXX'); break;
12 | case "6": console.log('XXXXXX.......XXX'); break;
13 | case "7": console.log('XXXXXXX.......XX'); break;
14 | case "8": console.log('XXXXXXXX.......X'); break;
15 | case "9": console.log('XXXXXXXXX.......'); break;
16 | }
17 | }
18 |
19 | function board(number){
20 | number.split("").reverse().forEach(function(digit){
21 | line(digit)
22 | })
23 | }
24 |
25 | function sleep(ms) {
26 | return new Promise(resolve => setTimeout(resolve, ms));
27 | }
28 |
29 | async function animate(number){
30 | if(number){
31 | let num = parseInt(number)
32 | for(var i=0; i 0) {
6 | temp = a;
7 | a = a + b;
8 | b = temp;
9 | num--;
10 | }
11 |
12 | return b;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/test/etc/javascript/fib-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Fibonacci",
3 | "description": "Fibonacci number generator",
4 | "version": "1.0.0",
5 | "dependencies": {
6 | "argparse": "latest"
7 | },
8 | "files": [
9 | "fib.js"
10 | ],
11 | "main": "app.js"
12 | }
13 |
--------------------------------------------------------------------------------
/test/etc/javascript/fib-project/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Simple test harness for the JavaScript Fibonacci number
4 | # project. $1 is the path to the instrumented project,
5 | # while $2 is the test case to execute.
6 |
7 | # Enter the instrumented project directory
8 | cd $1
9 | # Install the package dependencies (this should be done
10 | # prior to testing, but having it here avoids clutting
11 | # the SEL repository with no real harm)
12 | npm install
13 | # Execute the application against the given test case
14 | node ./app.js $2
15 |
--------------------------------------------------------------------------------
/test/etc/javascript/fib/fib.js:
--------------------------------------------------------------------------------
1 | function fibonacci(num) {
2 | var a = 1, b = 0, temp;
3 |
4 | while (num > 0) {
5 | temp = a;
6 | a = a + b;
7 | b = temp;
8 | num--;
9 | }
10 |
11 | return b;
12 | }
13 |
14 | fibonacci(10);
15 |
--------------------------------------------------------------------------------
/test/etc/javascript/fib/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | node $1
3 |
--------------------------------------------------------------------------------
/test/etc/javascript/hello-world/hello-world.js:
--------------------------------------------------------------------------------
1 | console.log("Hello World")
2 |
--------------------------------------------------------------------------------
/test/etc/javascript/package-json/base-d5da5eb.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "optimist",
3 | "version" : "0.5.2",
4 | "description" : "Light-weight option parsing with an argv hash. No optstrings attached.",
5 | "main" : "./index.js",
6 | "dependencies" : {
7 | "wordwrap" : "~0.0.2"
8 | },
9 | "devDependencies" : {
10 | "hashish": "~0.0.4",
11 | "tap" : "~0.4.0"
12 | },
13 | "scripts" : {
14 | "test" : "tap ./test/*.js"
15 | },
16 | "repository" : {
17 | "type" : "git",
18 | "url" : "http://github.com/substack/node-optimist.git"
19 | },
20 | "keywords" : [
21 | "argument",
22 | "args",
23 | "option",
24 | "parser",
25 | "parsing",
26 | "cli",
27 | "command"
28 | ],
29 | "author" : {
30 | "name" : "James Halliday",
31 | "email" : "mail@substack.net",
32 | "url" : "http://substack.net"
33 | },
34 | "license" : "MIT/X11",
35 | "engine" : {
36 | "node" : ">=0.4"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/test/etc/javascript/package-json/left-ea14630.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "optimist",
3 | "version" : "0.6.0",
4 | "description" : "Light-weight option parsing with an argv hash. No optstrings attached.",
5 | "main" : "./index.js",
6 | "dependencies" : {
7 | "wordwrap" : "~0.0.2",
8 | "minimist" : "~0.0.1"
9 | },
10 | "devDependencies" : {
11 | "hashish": "~0.0.4",
12 | "tap" : "~0.4.0"
13 | },
14 | "scripts" : {
15 | "test" : "tap ./test/*.js"
16 | },
17 | "repository" : {
18 | "type" : "git",
19 | "url" : "http://github.com/substack/node-optimist.git"
20 | },
21 | "keywords" : [
22 | "argument",
23 | "args",
24 | "option",
25 | "parser",
26 | "parsing",
27 | "cli",
28 | "command"
29 | ],
30 | "author" : {
31 | "name" : "James Halliday",
32 | "email" : "mail@substack.net",
33 | "url" : "http://substack.net"
34 | },
35 | "license" : "MIT/X11",
36 | "engine" : {
37 | "node" : ">=0.4"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/test/etc/javascript/package-json/right-6655688.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "optimist",
3 | "version" : "0.5.3",
4 | "description" : "Light-weight option parsing with an argv hash. No optstrings attached.",
5 | "main" : "./index.js",
6 | "dependencies" : {
7 | },
8 | "devDependencies" : {
9 | "hashish": "~0.0.4",
10 | "tap" : "~0.4.0"
11 | },
12 | "scripts" : {
13 | "test" : "tap ./test/*.js"
14 | },
15 | "repository" : {
16 | "type" : "git",
17 | "url" : "http://github.com/substack/node-optimist.git"
18 | },
19 | "keywords" : [
20 | "argument",
21 | "args",
22 | "option",
23 | "parser",
24 | "parsing",
25 | "cli",
26 | "command"
27 | ],
28 | "author" : {
29 | "name" : "James Halliday",
30 | "email" : "mail@substack.net",
31 | "url" : "http://substack.net"
32 | },
33 | "license" : "MIT/X11",
34 | "engine" : {
35 | "node" : ">=0.4"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/array-destructuring.js:
--------------------------------------------------------------------------------
1 | var arr = [1, 2, 3, 4, 5, 6];
2 | var [a, b, c, ... d] = arr;
3 | console.log("a, b, c, d: %s %s %s %s", a, b, c, d);
4 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/arrow-function-expression.js:
--------------------------------------------------------------------------------
1 | var materials = [
2 | 'Hydrogen',
3 | 'Helium',
4 | 'Lithium',
5 | 'Beryllium'
6 | ];
7 |
8 | console.log(materials.map(material => material.length));
9 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/await-expression.js:
--------------------------------------------------------------------------------
1 | function resolveAfter2Seconds(x) {
2 | return new Promise(resolve => {
3 | setTimeout(() => {
4 | resolve(x);
5 | }, 2000);
6 | });
7 | }
8 |
9 | async function f1() {
10 | var x = await resolveAfter2Seconds(10);
11 | console.log(x); // 10
12 | }
13 | f1();
14 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/class-declaration.js:
--------------------------------------------------------------------------------
1 | class Hero {
2 | constructor(name, level) {
3 | this.name = name;
4 | this.level = level;
5 | }
6 |
7 | // Adding a method to the constructor
8 | greet() {
9 | return `${this.name} says hello.`;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/class-expression.js:
--------------------------------------------------------------------------------
1 | let Rectangle = class {
2 | constructor(height, width) {
3 | this.height = height;
4 | this.width = width;
5 | }
6 | };
7 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/conditional-expression.js:
--------------------------------------------------------------------------------
1 | function getFee(isMember) {
2 | return (isMember ? "$2.00" : "$10.00");
3 | }
4 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/debugger-statement.js:
--------------------------------------------------------------------------------
1 | debugger;
2 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/empty-statement.js:
--------------------------------------------------------------------------------
1 | ;
2 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/export-specifier.js:
--------------------------------------------------------------------------------
1 | export { a } from "source"
2 | export { b as c } from "source"
3 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/expression-statement.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/function-declaration.js:
--------------------------------------------------------------------------------
1 | function foo(a = 1, b = 2, ...c) {
2 | return 0;
3 | }
4 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/function-expression.js:
--------------------------------------------------------------------------------
1 | var foo = function (a = 1, b = 2, ...c) {
2 | return 0;
3 | }
4 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/if.js:
--------------------------------------------------------------------------------
1 | var val = 1;
2 |
3 | if (val == 1) {
4 | console.log("HERE");
5 | } else {
6 | console.log("THERE");
7 | }
8 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/import-specifier.js:
--------------------------------------------------------------------------------
1 | import { a } from "source"
2 | import { b as c } from "source"
3 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/labeled-statement.js:
--------------------------------------------------------------------------------
1 | foo:
2 | log.console("HI");
3 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/loops.js:
--------------------------------------------------------------------------------
1 | function* foo() {
2 | yield 1;
3 | yield 2;
4 | yield 3;
5 | }
6 |
7 | for (var i = 1; i <= 3; i++) {
8 | console.log(i);
9 | }
10 |
11 | var arr = [1, 2, 3];
12 | for (var i in arr) {
13 | console.log(arr[i]);
14 | }
15 |
16 | for (let val of foo()) {
17 | console.log(val);
18 | }
19 |
20 | var i = 1;
21 | while (i <= 3) {
22 | console.log(i);
23 | i++;
24 | }
25 |
26 | i = 1;
27 | do {
28 | console.log(i);
29 | i++;
30 | } while (i <= 3);
31 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/new-expression.js:
--------------------------------------------------------------------------------
1 | var a = new Number(5);
2 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/object-destructuring.js:
--------------------------------------------------------------------------------
1 | var o = {p: 42, q: true};
2 | var {p, q} = o;
3 | console.log("p, q: %s %d", p, q);
4 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/object-expression.js:
--------------------------------------------------------------------------------
1 | var object1 = {a: 'foo', b: 42, c: {}};
2 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/property.js:
--------------------------------------------------------------------------------
1 | var o = {p: 42, q: true};
2 | var {p, q} = o;
3 | pp.parseTemplate = function({isTagged = false} = {}) {
4 | let node = this.startNode()
5 | this.next()
6 | node.expressions = []
7 | let curElt = this.parseTemplateElement({isTagged})
8 | node.quasis = [curElt]
9 | while (!curElt.tail) {
10 | if (this.type === tt.eof) this.raise(this.pos, "Unterminated template literal")
11 | this.expect(tt.dollarBraceL)
12 | node.expressions.push(this.parseExpression())
13 | this.expect(tt.braceR)
14 | node.quasis.push(curElt = this.parseTemplateElement({isTagged}))
15 | }
16 | this.next()
17 | return this.finishNode(node, "TemplateLiteral")
18 | }
19 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/sequence-expression.js:
--------------------------------------------------------------------------------
1 | (4, 8);
2 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/spread-element.js:
--------------------------------------------------------------------------------
1 | var a = 1;
2 | var b = 2;
3 | var c = [3, 4, 5];
4 | var arr = [a, b,...c];
5 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/switch.js:
--------------------------------------------------------------------------------
1 | var day;
2 |
3 | switch (new Date().getDay()) {
4 | case 0:
5 | day = "Sunday";
6 | break;
7 | case 1:
8 | day = "Monday";
9 | break;
10 | case 2:
11 | day = "Tuesday";
12 | break;
13 | case 3:
14 | day = "Wednesday";
15 | break;
16 | case 4:
17 | day = "Thursday";
18 | break;
19 | case 5:
20 | day = "Friday";
21 | break;
22 | case 6:
23 | day = "Saturday";
24 | break;
25 | }
26 |
27 | console.log(day);
28 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/tagged-template-expression.js:
--------------------------------------------------------------------------------
1 | const myTag = (literals, name) => {
2 | console.log('Literals', literals); //Output -> Literals [ 'Hello ', '!' ]
3 | console.log('Interpolation', name); //Output -> Interpolation Steve
4 |
5 | return 'Result from myTag';
6 | };
7 |
8 | const name = 'Steve';
9 | const result = myTag `Hello ${name}!`;
10 |
11 | console.log(result); //Output -> Result from myTag
12 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/try-catch-throw.js:
--------------------------------------------------------------------------------
1 | try {
2 | throw "HI";
3 | } catch (err) {
4 | console.error(err);
5 | }
6 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/with-statement.js:
--------------------------------------------------------------------------------
1 | var o = { first: "John" };
2 |
3 | with(o) {
4 | console.log("Hello "+first);
5 | }
6 |
--------------------------------------------------------------------------------
/test/etc/javascript/parsing/yield-expression.js:
--------------------------------------------------------------------------------
1 | function* foo(index) {
2 | while (index < 2) {
3 | yield index++;
4 | }
5 | }
6 |
7 | const iterator = foo(0);
8 |
9 | console.log(iterator.next().value);
10 | // expected output: 0
11 |
12 | console.log(iterator.next().value);
13 |
--------------------------------------------------------------------------------
/test/etc/javascript/trivial.json:
--------------------------------------------------------------------------------
1 | {
2 | "trivial": true,
3 | "size": "small",
4 | "number": 9
5 | }
6 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/#OcTree.h#:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_OCTREE_H
35 | #define OCTOMAP_OCTREE_H
36 |
37 |
38 | #include "OccupancyOcTreeBase.h"
39 | #include "OcTreeNode.h"
40 | #include "ScanGraph.h"
41 |
42 | namespace octomap {
43 |
44 | /**
45 | * octomap main map data structure, stores 3D occupancy grid map in an OcTree.
46 | * Basic functionality is implemented in OcTreeBase.
47 | *
48 | */
49 | class OcTree : public OccupancyOcTreeBase {
50 |
51 | public:
52 | /// Default constructor, sets resolution of leafs
53 | OcTree(double resolution);
54 |
55 | /**
56 | * Reads an OcTree from a binary file
57 | * @param _filename
58 | *
59 | */
60 | OcTree(std::string _filename);
61 |
62 | virtual ~OcTree(){};
63 |
64 | /// virtual constructor: creates a new object of same type
65 | /// (Covariant return type requires an up-to-date compiler)
66 | OcTree* create() const {return new OcTree(resolution); }
67 |
68 | std::string getTreeType() const {return "OcTree";}
69 |
70 |
71 | protected:
72 | /**
73 | * Static member object which ensures that this OcTree's prototype
74 | * ends up in the classIDMapping only once. You need this as a
75 | * static member in any derived octree class in order to read .ot
76 | * files through the AbstractOcTree factory. You should also call
77 | * ensureLinking() once from the constructor.
78 | */
79 | class StaticMemberInitializer{
80 | public:
81 | StaticMemberInitializer() {
82 | OcTree* tree = new OcTree(0.1);
83 | AbstractOcTree::registerTreeType(tree);
84 | }
85 |
86 | /**
87 | * Dummy function to ensure that MSVC does not drop the
88 | * StaticMemberInitializer, causing this tree failing to register.
89 | * Needs to be called from the constructor of this octree.
90 | */
91 | void ensureLinking() {};
92 | };
93 |
94 | /// to ensure static initialization (only once)
95 | static StaticMemberInitializer ocTreeMemberInit;
96 | };
97 |
98 | } // end namespace
99 |
100 | #endif
101 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/MapNode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_MAP_NODE_H
35 | #define OCTOMAP_MAP_NODE_H
36 |
37 |
38 | #include
39 | #include
40 |
41 | namespace octomap {
42 |
43 | template
44 | class MapNode {
45 |
46 | public:
47 | MapNode();
48 | MapNode(TREETYPE* node_map, pose6d origin);
49 | MapNode(std::string filename, pose6d origin);
50 | MapNode(const Pointcloud& cloud, pose6d origin);
51 | ~MapNode();
52 |
53 | typedef TREETYPE TreeType;
54 |
55 | TREETYPE* getMap() { return node_map; }
56 |
57 | void updateMap(const Pointcloud& cloud, point3d sensor_origin);
58 |
59 | inline std::string getId() { return id; }
60 | inline void setId(std::string newid) { id = newid; }
61 |
62 | inline pose6d getOrigin() { return origin; }
63 |
64 | // returns cloud of voxel centers in global reference frame
65 | Pointcloud generatePointcloud();
66 | bool writeMap(std::string filename);
67 |
68 | protected:
69 | TREETYPE* node_map; // occupancy grid map
70 | pose6d origin; // origin and orientation relative to parent
71 | std::string id;
72 |
73 | void clear();
74 | bool readMap(std::string filename);
75 |
76 | };
77 |
78 | } // end namespace
79 |
80 | #include "octomap/MapNode.hxx"
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/MapNode.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | namespace octomap {
35 |
36 | template
37 | MapNode::MapNode(): node_map(0) {
38 | }
39 |
40 | template
41 | MapNode::MapNode(TREETYPE* node_map, pose6d origin) {
42 | this->node_map = node_map;
43 | this->origin = origin;
44 | }
45 |
46 | template
47 | MapNode::MapNode(const Pointcloud& cloud, pose6d origin): node_map(0) {
48 | }
49 |
50 | template
51 | MapNode::MapNode(std::string filename, pose6d origin): node_map(0){
52 | readMap(filename);
53 | this->origin = origin;
54 | id = filename;
55 | }
56 |
57 | template
58 | MapNode::~MapNode() {
59 | clear();
60 | }
61 |
62 | template
63 | void MapNode::updateMap(const Pointcloud& cloud, point3d sensor_origin) {
64 | }
65 |
66 | template
67 | Pointcloud MapNode::generatePointcloud() {
68 | Pointcloud pc;
69 | point3d_list occs;
70 | node_map->getOccupied(occs);
71 | for(point3d_list::iterator it = occs.begin(); it != occs.end(); ++it){
72 | pc.push_back(*it);
73 | }
74 | return pc;
75 | }
76 |
77 | template
78 | void MapNode::clear(){
79 | if(node_map != 0){
80 | delete node_map;
81 | node_map = 0;
82 | id = "";
83 | origin = pose6d(0.0,0.0,0.0,0.0,0.0,0.0);
84 | }
85 | }
86 |
87 | template
88 | bool MapNode::readMap(std::string filename){
89 | if(node_map != 0)
90 | delete node_map;
91 |
92 | node_map = new TREETYPE(0.05);
93 | return node_map->readBinary(filename);
94 | }
95 |
96 | template
97 | bool MapNode::writeMap(std::string filename){
98 | return node_map->writeBinary(filename);
99 | }
100 |
101 | } // namespace
102 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/OcTreeBase.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_OCTREE_BASE_H
35 | #define OCTOMAP_OCTREE_BASE_H
36 |
37 |
38 | #include "OcTreeBaseImpl.h"
39 | #include "AbstractOcTree.h"
40 |
41 |
42 | namespace octomap {
43 | template
44 | class OcTreeBase : public OcTreeBaseImpl {
45 | public:
46 | OcTreeBase(double res) : OcTreeBaseImpl(res) {};
47 |
48 | /// virtual constructor: creates a new object of same type
49 | /// (Covariant return type requires an up-to-date compiler)
50 | OcTreeBase* create() const {return new OcTreeBase(this->resolution); }
51 | std::string getTreeType() const {return "OcTreeBase";}
52 | };
53 |
54 | };
55 |
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/OcTreeBaseSE.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_OCTREE_BASE_SE_H
35 | #define OCTOMAP_OCTREE_BASE_SE_H
36 |
37 |
38 | #include "OcTreeBase.h"
39 | #include "OcTreeLUT.h"
40 |
41 |
42 | namespace octomap {
43 |
44 |
45 | template
46 | class OcTreeBaseSE: public OcTreeBase {
47 |
48 | public:
49 |
50 | OcTreeBaseSE(double _resolution);
51 | virtual ~OcTreeBaseSE();
52 |
53 | /**
54 | * Traces a ray from origin to end (excluding), returning the
55 | * coordinates of all nodes traversed by the beam.
56 | * (Essentially using the DDA algorithm in 3D).
57 | *
58 | * @param origin start coordinate of ray
59 | * @param end end coordinate of ray
60 | * @param ray KeyRay structure that holds the keys of all nodes traversed by the ray, excluding "end"
61 | * @return Success of operation. Returning false usually means that one of the coordinates is out of the OcTree's range
62 | */
63 | bool computeRayKeys(const point3d& origin, const point3d& end, KeyRay& ray) const;
64 |
65 | NODE* getLUTNeighbor(const point3d& value, OcTreeLUT::NeighborDirection dir) const;
66 |
67 |
68 | protected:
69 |
70 | KeyRay keyray;
71 | OcTreeLUT* lut;
72 |
73 | };
74 |
75 |
76 | }
77 |
78 | #include "OcTreeBaseSE.hxx"
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/math/Utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMATH_UTILS_H
35 | #define OCTOMATH_UTILS_H
36 |
37 | #ifndef M_PI
38 | #define M_PI 3.14159265358979323846
39 | #endif
40 |
41 | #ifndef M_PI_2
42 | #define M_PI_2 1.570796326794896619
43 | #endif
44 |
45 |
46 | #ifndef DEG2RAD
47 | #define DEG2RAD(x) ((x) * 0.01745329251994329575)
48 | #endif
49 |
50 | #ifndef RAD2DEG
51 | #define RAD2DEG(x) ((x) * 57.29577951308232087721)
52 | #endif
53 |
54 |
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/octomap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #include "octomap_types.h"
35 | #include "Pointcloud.h"
36 | #include "ScanGraph.h"
37 | #include "OcTree.h"
38 |
39 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/octomap_deprecated.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_DEPRECATED_H
35 | #define OCTOMAP_DEPRECATED_H
36 |
37 | // define multi-platform deprecation mechanism
38 | #ifndef OCTOMAP_DEPRECATED
39 | #ifdef __GNUC__
40 | #define OCTOMAP_DEPRECATED(func) func __attribute__ ((deprecated))
41 | #elif defined(_MSC_VER)
42 | #define OCTOMAP_DEPRECATED(func) __declspec(deprecated) func
43 | #else
44 | #pragma message("WARNING: You need to implement OCTOMAP_DEPRECATED for this compiler")
45 | #define OCTOMAP_DEPRECATED(func) func
46 | #endif
47 | #endif
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/octomap_timing.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_TIMING_H_
35 | #define OCTOMAP_TIMING_H_
36 |
37 | #ifdef _MSC_VER
38 | // MS compilers
39 | #include
40 | #include
41 | #include
42 | void gettimeofday(struct timeval* t, void* timezone) {
43 | struct _timeb timebuffer;
44 | _ftime64_s( &timebuffer );
45 | t->tv_sec= (long) timebuffer.time;
46 | t->tv_usec=1000*timebuffer.millitm;
47 | }
48 | #else
49 | // GCC and minGW
50 | #include
51 | #endif
52 |
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/include/octomap/octomap_utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_UTILS_H_
35 | #define OCTOMAP_UTILS_H_
36 |
37 | #include
38 |
39 | namespace octomap{
40 |
41 | /// compute log-odds from probability:
42 | inline float logodds(double probability){
43 | return (float) log(probability/(1-probability));
44 | }
45 |
46 | /// compute probability from logodds:
47 | inline double probability(double logodds){
48 | return 1. - ( 1. / (1. + exp(logodds)));
49 |
50 | }
51 | }
52 |
53 |
54 |
55 | #endif /* OCTOMAP_UTILS_H_ */
56 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.7.2/src/testing.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // this is mimicing gtest expressions
5 |
6 | #define EXPECT_TRUE(args) { \
7 | if (!(args)) { fprintf(stderr, "test failed (EXPECT_TRUE) in %s, line %d\n", __FILE__, __LINE__); \
8 | exit(1); \
9 | } }
10 |
11 | #define EXPECT_FALSE(args) { \
12 | if (args) { fprintf(stderr, "test failed (EXPECT_FALSE) in %s, line %d\n", __FILE__, __LINE__); \
13 | exit(1); \
14 | } }
15 |
16 | #define EXPECT_EQ(a,b) { \
17 | if (!(a == b)) { std::cerr << "test failed: " < %f in %s, line %d\n", a, b, prec, __FILE__, __LINE__); \
29 | exit(1); \
30 | } }
31 |
32 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/MapNode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_MAP_NODE_H
35 | #define OCTOMAP_MAP_NODE_H
36 |
37 |
38 | #include
39 | #include
40 |
41 | namespace octomap {
42 |
43 | template
44 | class MapNode {
45 |
46 | public:
47 | MapNode();
48 | MapNode(TREETYPE* node_map, pose6d origin);
49 | MapNode(std::string filename, pose6d origin);
50 | MapNode(const Pointcloud& cloud, pose6d origin);
51 | ~MapNode();
52 |
53 | typedef TREETYPE TreeType;
54 |
55 | TREETYPE* getMap() { return node_map; }
56 |
57 | void updateMap(const Pointcloud& cloud, point3d sensor_origin);
58 |
59 | inline std::string getId() { return id; }
60 | inline void setId(std::string newid) { id = newid; }
61 |
62 | inline pose6d getOrigin() { return origin; }
63 |
64 | // returns cloud of voxel centers in global reference frame
65 | Pointcloud generatePointcloud();
66 | bool writeMap(std::string filename);
67 |
68 | protected:
69 | TREETYPE* node_map; // occupancy grid map
70 | pose6d origin; // origin and orientation relative to parent
71 | std::string id;
72 |
73 | void clear();
74 | bool readMap(std::string filename);
75 |
76 | };
77 |
78 | } // end namespace
79 |
80 | #include "octomap/MapNode.hxx"
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/MapNode.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | namespace octomap {
35 |
36 | template
37 | MapNode::MapNode(): node_map(0) {
38 | }
39 |
40 | template
41 | MapNode::MapNode(TREETYPE* node_map, pose6d origin) {
42 | this->node_map = node_map;
43 | this->origin = origin;
44 | }
45 |
46 | template
47 | MapNode::MapNode(const Pointcloud& cloud, pose6d origin): node_map(0) {
48 | }
49 |
50 | template
51 | MapNode::MapNode(std::string filename, pose6d origin): node_map(0){
52 | readMap(filename);
53 | this->origin = origin;
54 | id = filename;
55 | }
56 |
57 | template
58 | MapNode::~MapNode() {
59 | clear();
60 | }
61 |
62 | template
63 | void MapNode::updateMap(const Pointcloud& cloud, point3d sensor_origin) {
64 | }
65 |
66 | template
67 | Pointcloud MapNode::generatePointcloud() {
68 | Pointcloud pc;
69 | point3d_list occs;
70 | node_map->getOccupied(occs);
71 | for(point3d_list::iterator it = occs.begin(); it != occs.end(); ++it){
72 | pc.push_back(*it);
73 | }
74 | return pc;
75 | }
76 |
77 | template
78 | void MapNode::clear(){
79 | if(node_map != 0){
80 | delete node_map;
81 | node_map = 0;
82 | id = "";
83 | origin = pose6d(0.0,0.0,0.0,0.0,0.0,0.0);
84 | }
85 | }
86 |
87 | template
88 | bool MapNode::readMap(std::string filename){
89 | if(node_map != 0)
90 | delete node_map;
91 |
92 | node_map = new TREETYPE(0.05);
93 | return node_map->readBinary(filename);
94 | }
95 |
96 | template
97 | bool MapNode::writeMap(std::string filename){
98 | return node_map->writeBinary(filename);
99 | }
100 |
101 | } // namespace
102 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/OcTreeBase.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_OCTREE_BASE_H
35 | #define OCTOMAP_OCTREE_BASE_H
36 |
37 |
38 | #include "OcTreeBaseImpl.h"
39 | #include "AbstractOcTree.h"
40 |
41 |
42 | namespace octomap {
43 | template
44 | class OcTreeBase : public OcTreeBaseImpl {
45 | public:
46 | OcTreeBase(double res) : OcTreeBaseImpl(res) {};
47 |
48 | /// virtual constructor: creates a new object of same type
49 | /// (Covariant return type requires an up-to-date compiler)
50 | OcTreeBase* create() const {return new OcTreeBase(this->resolution); }
51 | std::string getTreeType() const {return "OcTreeBase";}
52 | };
53 |
54 | };
55 |
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/OcTreeNode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_OCTREE_NODE_H
35 | #define OCTOMAP_OCTREE_NODE_H
36 |
37 | #include "octomap_types.h"
38 | #include "octomap_utils.h"
39 | #include "OcTreeDataNode.h"
40 | #include
41 |
42 | namespace octomap {
43 |
44 | /**
45 | * Nodes to be used in OcTree. They represent 3d occupancy grid cells.
46 | * "value" stores their log-odds occupancy.
47 | *
48 | * Note: If you derive a class (directly or indirectly) from OcTreeNode or
49 | * OcTreeDataNode, you have to implement (at least) the following functions:
50 | * createChild(), getChild(), getChild() const, expandNode() to avoid slicing
51 | * errors and memory-related bugs.
52 | * See ColorOcTreeNode in ColorOcTree.h for an example.
53 | *
54 | */
55 | class OcTreeNode : public OcTreeDataNode {
56 |
57 | public:
58 | OcTreeNode();
59 | ~OcTreeNode();
60 |
61 |
62 | // -- node occupancy ----------------------------
63 |
64 | /// \return occupancy probability of node
65 | inline double getOccupancy() const { return probability(value); }
66 |
67 | /// \return log odds representation of occupancy probability of node
68 | inline float getLogOdds() const{ return value; }
69 | /// sets log odds occupancy of node
70 | inline void setLogOdds(float l) { value = l; }
71 |
72 | /**
73 | * @return mean of all children's occupancy probabilities, in log odds
74 | */
75 | double getMeanChildLogOdds() const;
76 |
77 | /**
78 | * @return maximum of children's occupancy probabilities, in log odds
79 | */
80 | float getMaxChildLogOdds() const;
81 |
82 | /// update this node's occupancy according to its children's maximum occupancy
83 | inline void updateOccupancyChildren() {
84 | this->setLogOdds(this->getMaxChildLogOdds()); // conservative
85 | }
86 |
87 | /// adds p to the node's logOdds value (with no boundary / threshold checking!)
88 | void addValue(const float& p);
89 |
90 |
91 | protected:
92 | // "value" stores log odds occupancy probability
93 | };
94 |
95 | } // end namespace
96 |
97 | #endif
98 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/math/Utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMATH_UTILS_H
35 | #define OCTOMATH_UTILS_H
36 |
37 | #ifndef M_PI
38 | #define M_PI 3.14159265358979323846
39 | #endif
40 |
41 | #ifndef M_PI_2
42 | #define M_PI_2 1.570796326794896619
43 | #endif
44 |
45 |
46 | #ifndef DEG2RAD
47 | #define DEG2RAD(x) ((x) * 0.01745329251994329575)
48 | #endif
49 |
50 | #ifndef RAD2DEG
51 | #define RAD2DEG(x) ((x) * 57.29577951308232087721)
52 | #endif
53 |
54 |
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/octomap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #include "octomap_types.h"
35 | #include "Pointcloud.h"
36 | #include "ScanGraph.h"
37 | #include "OcTree.h"
38 |
39 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/octomap_deprecated.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_DEPRECATED_H
35 | #define OCTOMAP_DEPRECATED_H
36 |
37 | // define multi-platform deprecation mechanism
38 | #ifndef OCTOMAP_DEPRECATED
39 | #ifdef __GNUC__
40 | #define OCTOMAP_DEPRECATED(func) func __attribute__ ((deprecated))
41 | #elif defined(_MSC_VER)
42 | #define OCTOMAP_DEPRECATED(func) __declspec(deprecated) func
43 | #else
44 | #pragma message("WARNING: You need to implement OCTOMAP_DEPRECATED for this compiler")
45 | #define OCTOMAP_DEPRECATED(func) func
46 | #endif
47 | #endif
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/octomap_timing.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_TIMING_H_
35 | #define OCTOMAP_TIMING_H_
36 |
37 | #ifdef _MSC_VER
38 | // MS compilers
39 | #include
40 | #include
41 | #include
42 | void gettimeofday(struct timeval* t, void* timezone) {
43 | struct _timeb timebuffer;
44 | _ftime64_s( &timebuffer );
45 | t->tv_sec= (long) timebuffer.time;
46 | t->tv_usec=1000*timebuffer.millitm;
47 | }
48 | #else
49 | // GCC and minGW
50 | #include
51 | #endif
52 |
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/octomap_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_TYPES_H
35 | #define OCTOMAP_TYPES_H
36 |
37 | #include
38 | #include
39 | #include
40 |
41 | #include
42 | #include
43 | #include
44 |
45 | namespace octomap {
46 |
47 | ///Use Vector3 (float precision) as a point3d in octomap
48 | typedef octomath::Vector3 point3d;
49 | /// Use our Pose6D (float precision) as pose6d in octomap
50 | typedef octomath::Pose6D pose6d;
51 |
52 | typedef std::vector point3d_collection;
53 | typedef std::list point3d_list;
54 |
55 | /// A voxel defined by its center point3d and its side length
56 | typedef std::pair OcTreeVolume;
57 |
58 | }
59 |
60 | // no debug output if not in debug mode:
61 | #ifdef NDEBUG
62 | #ifndef OCTOMAP_NODEBUGOUT
63 | #define OCTOMAP_NODEBUGOUT
64 | #endif
65 | #endif
66 |
67 | #ifdef OCTOMAP_NODEBUGOUT
68 | #define OCTOMAP_DEBUG(...) (void)0
69 | #define OCTOMAP_DEBUG_STR(...) (void)0
70 | #else
71 | #define OCTOMAP_DEBUG(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
72 | #define OCTOMAP_DEBUG_STR(args) std::cerr << args << std::endl
73 | #endif
74 |
75 | #define OCTOMAP_WARNING(...) fprintf(stderr, "WARNING: "), fprintf(stderr, __VA_ARGS__), fflush(stderr)
76 | #define OCTOMAP_WARNING_STR(args) std::cerr << "WARNING: " << args << std::endl
77 | #define OCTOMAP_ERROR(...) fprintf(stderr, "ERROR: "), fprintf(stderr, __VA_ARGS__), fflush(stderr)
78 | #define OCTOMAP_ERROR_STR(args) std::cerr << "ERROR: " << args << std::endl
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/include/octomap/octomap_utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OctoMap - An Efficient Probabilistic 3D Mapping Framework Based on Octrees
3 | * http://octomap.github.com/
4 | *
5 | * Copyright (c) 2009-2013, K.M. Wurm and A. Hornung, University of Freiburg
6 | * All rights reserved.
7 | * License: New BSD
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions are met:
11 | *
12 | * * Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * * Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * * Neither the name of the University of Freiburg nor the names of its
18 | * contributors may be used to endorse or promote products derived from
19 | * this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 | * POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef OCTOMAP_UTILS_H_
35 | #define OCTOMAP_UTILS_H_
36 |
37 | #include
38 |
39 | namespace octomap{
40 |
41 | /// compute log-odds from probability:
42 | inline float logodds(double probability){
43 | return (float) log(probability/(1-probability));
44 | }
45 |
46 | /// compute probability from logodds:
47 | inline double probability(double logodds){
48 | return 1. - ( 1. / (1. + exp(logodds)));
49 |
50 | }
51 | }
52 |
53 |
54 |
55 | #endif /* OCTOMAP_UTILS_H_ */
56 |
--------------------------------------------------------------------------------
/test/etc/octomap/octomap-1.8.0/src/testing.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | // this is mimicing gtest expressions
5 |
6 | #define EXPECT_TRUE(args) { \
7 | if (!(args)) { fprintf(stderr, "test failed (EXPECT_TRUE) in %s, line %d\n", __FILE__, __LINE__); \
8 | exit(1); \
9 | } }
10 |
11 | #define EXPECT_FALSE(args) { \
12 | if (args) { fprintf(stderr, "test failed (EXPECT_FALSE) in %s, line %d\n", __FILE__, __LINE__); \
13 | exit(1); \
14 | } }
15 |
16 | #define EXPECT_EQ(a,b) { \
17 | if (!(a == b)) { std::cerr << "test failed: " < %f in %s, line %d\n", a, b, prec, __FILE__, __LINE__); \
29 | exit(1); \
30 | } }
31 |
32 |
--------------------------------------------------------------------------------
/test/etc/read_words.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | char** read_words(FILE* fp, char** words) {
4 | unsigned int char_index = 0;
5 | unsigned int words_index = 0;
6 | char ch = fgetc(fp);
7 | while(ch != EOF) {
8 | if(ch == '\n' || char_index >= 255) {
9 | words[words_index][char_index] = '\0';
10 | words_index += 1;
11 | char_index = 0;
12 | }
13 | else {
14 | words[words_index][char_index] = ch;
15 | char_index += 1;
16 | }
17 | ch = fgetc(fp);
18 | }
19 | return words;
20 | }
21 |
--------------------------------------------------------------------------------
/test/etc/sed-compile/Makefile:
--------------------------------------------------------------------------------
1 | ast-diff:
2 | @! ast-diff --old-flags "-c" --new-flags "-c" compile-before.c compile-after.c
3 |
--------------------------------------------------------------------------------
/test/etc/sed-compile/basicdefs.h:
--------------------------------------------------------------------------------
1 | /* GNU SED, a batch stream editor.
2 | Copyright (C) 1998, 1999, 2002, 2003, 2010 Free Software Foundation, Inc.
3 |
4 | This program is free software; you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation; either version 2, or (at your option)
7 | any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program; if not, write to the Free Software
16 | Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 |
18 | #ifndef BASICDEFS_H
19 | #define BASICDEFS_H
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | // #include
28 | #include
29 | // #define N_(String) gettext_noop(String)
30 | #define N_(String) String
31 | #define _(String) gettext(String)
32 |
33 | #define SED_FEATURE_VERSION "0.0"
34 |
35 | /* type countT is used to keep track of line numbers, etc. */
36 | typedef unsigned long countT;
37 |
38 | /* some basic definitions to avoid undue promulgating of ugliness */
39 | #define MALLOC(n,t) ((t *)ck_malloc((n)*sizeof(t)))
40 | #define REALLOC(x,n,t) ((t *)ck_realloc((void *)(x),(n)*sizeof(t)))
41 | #define MEMDUP(x,n,t) ((t *)ck_memdup((void *)(x),(n)*sizeof(t)))
42 | #define OB_MALLOC(o,n,t) ((t *)(void *)obstack_alloc(o,(n)*sizeof(t)))
43 |
44 | #define obstack_chunk_alloc ck_malloc
45 | #define obstack_chunk_free free
46 |
47 |
48 | /* handle misdesigned macros (snarfed from lib/regex.c) */
49 | /* Jim Meyering writes:
50 |
51 | "... Some ctype macros are valid only for character codes that
52 | isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
53 | using /bin/cc or gcc but without giving an ansi option). So, all
54 | ctype uses should be through macros like ISPRINT... If
55 | STDC_HEADERS is defined, then autoconf has verified that the ctype
56 | macros don't need to be guarded with references to isascii. ...
57 | Defining isascii to 1 should let any compiler worth its salt
58 | eliminate the && through constant folding."
59 | Solaris defines some of these symbols so we must undefine them first. */
60 |
61 | #undef ISASCII
62 | #if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
63 | # define ISASCII(c) 1
64 | #else
65 | # define ISASCII(c) isascii(c)
66 | #endif
67 |
68 | #if defined isblank || defined HAVE_ISBLANK
69 | # define ISBLANK(c) (ISASCII (c) && isblank (c))
70 | #else
71 | # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
72 | #endif
73 |
74 | #undef ISPRINT
75 | #define ISPRINT(c) (ISASCII (c) && isprint (c))
76 | #define ISDIGIT(c) (ISASCII (c) && isdigit ((unsigned char) (c)))
77 | #define ISALNUM(c) (ISASCII (c) && isalnum (c))
78 | #define ISALPHA(c) (ISASCII (c) && isalpha (c))
79 | #define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
80 | #define ISLOWER(c) (ISASCII (c) && islower (c))
81 | #define ISPUNCT(c) (ISASCII (c) && ispunct (c))
82 | #define ISSPACE(c) (ISASCII (c) && isspace (c))
83 | #define ISUPPER(c) (ISASCII (c) && isupper (c))
84 | #define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
85 |
86 | #ifndef initialize_main
87 | # ifdef __EMX__
88 | # define initialize_main(argcp, argvp) \
89 | { _response(argcp, argvp); _wildcard(argcp, argvp); }
90 | # else /* NOT __EMX__ */
91 | # define initialize_main(argcp, argvp)
92 | # endif
93 | #endif
94 |
95 | #endif /*!BASICDEFS_H*/
96 |
--------------------------------------------------------------------------------
/test/etc/sed-compile/utils.h:
--------------------------------------------------------------------------------
1 | /* Functions from hack's utils library.
2 | Copyright (C) 1989, 1990, 1991, 1998, 1999, 2003
3 | Free Software Foundation, Inc.
4 |
5 | This program is free software; you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation; either version 3, or (at your option)
8 | any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, write to the Free Software
17 | Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 |
19 | #include
20 |
21 | #include "basicdefs.h"
22 |
23 | void panic (const char *str, ...);
24 |
25 | FILE *ck_fopen (const char *name, const char *mode, int fail);
26 | FILE *ck_fdopen (int fd, const char *name, const char *mode, int fail);
27 | void ck_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
28 | size_t ck_fread (void *ptr, size_t size, size_t nmemb, FILE *stream);
29 | void ck_fflush (FILE *stream);
30 | void ck_fclose (FILE *stream);
31 | const char *follow_symlink (const char *path);
32 | size_t ck_getdelim (char **text, size_t *buflen, char buffer_delimiter, FILE *stream);
33 | FILE * ck_mkstemp (char **p_filename, const char *tmpdir, const char *base,
34 | const char *mode);
35 | void ck_rename (const char *from, const char *to, const char *unlink_if_fail);
36 |
37 | void *ck_malloc (size_t size);
38 | void *xmalloc (size_t size);
39 | void *ck_realloc (void *ptr, size_t size);
40 | char *ck_strdup (const char *str);
41 | void *ck_memdup (const void *buf, size_t len);
42 |
43 | struct buffer *init_buffer (void);
44 | char *get_buffer (struct buffer *b);
45 | size_t size_buffer (struct buffer *b);
46 | char *add_buffer (struct buffer *b, const char *p, size_t n);
47 | char *add1_buffer (struct buffer *b, int ch);
48 | void free_buffer (struct buffer *b);
49 |
50 | extern const char *myname;
51 |
--------------------------------------------------------------------------------
/test/etc/simple/seq-10-edit.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | 2
4 | 4
5 | 5
6 | 6
7 | seven
8 | 8
9 | 9
10 | 10
11 |
--------------------------------------------------------------------------------
/test/etc/simple/seq-10.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
6 | 6
7 | 7
8 | 8
9 | 9
10 | 10
11 |
--------------------------------------------------------------------------------
/test/etc/simple/simple-loop-after.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | int a = atoi(argv[1]);;
6 | int b = atoi(argv[2]);
7 |
8 | for(int i = b; i
2 | #include
3 |
4 | int main(int argc, char *argv[]) {
5 | int a = atoi(argv[1]);;
6 | int b = atoi(argv[2]);
7 |
8 | for(int i = a; i