Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions wp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ all: install

.PHONY: clean
clean:
@printf $(FMT_STR) "CLEANING LIB"
$(MAKE) -C $(LIB) clean
@printf $(FMT_STR) "CLEANING PLUGIN"
$(MAKE) -C $(PLUGIN) clean
@printf $(FMT_STR) "CLEANING LIB"
$(MAKE) -C $(LIB) clean

#####################################################
# BUILD
Expand All @@ -46,7 +46,7 @@ build.plugin: build.lib install.lib
#####################################################

.PHONY: install
install: uninstall.plugin install.plugin
install: install.plugin

.PHONY: uninstall
uninstall: uninstall.lib uninstall.plugin
Expand Down
2 changes: 1 addition & 1 deletion wp/lib/bap_wp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ clean.local:
#####################################################

$(BUILD): $(SRC_FILES)
dune build -p $(PROJECT)
dune build -p $(PROJECT) @install
touch $(BUILD)

.PHONY: build
Expand Down
2 changes: 1 addition & 1 deletion wp/lib/bap_wp/src/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(library
(name bap_wp)
(public_name bap_wp)
(libraries bap bap-x86-cpu bap-arm z3 ounit2 re str)
(libraries bap-main bap-x86-cpu bap-arm z3 ounit2 re str)
(preprocess (pps ppx_sexp_conv ppx_bin_prot)))
2 changes: 1 addition & 1 deletion wp/lib/bap_wp/tests/performance/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(test
(name test)
(libraries bap z3 ounit2 bap_wp))
(libraries z3 ounit2 bap_wp))
2 changes: 1 addition & 1 deletion wp/lib/bap_wp/tests/unit/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(test
(name test)
(libraries bap z3 ounit2 bap_wp))
(libraries z3 ounit2 bap_wp))
1 change: 1 addition & 0 deletions wp/plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.install
14 changes: 0 additions & 14 deletions wp/plugin/.merlin

This file was deleted.

59 changes: 10 additions & 49 deletions wp/plugin/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
PASS_NAME := wp
SHELL := /bin/bash

SAMPLE_BIN_DIR := ../resources/sample_binaries
API_PATH := $(shell bap --api-list-paths)
API_PATH := $(shell bap config sysdatadir)/api
VERIFIER_LOCAL := api/c/cbat.h
VERIFIER_INSTALL_PATH := $(API_PATH)/c/cbat.h

PKGS := 'z3,bap_wp,re,str'
TAG := 'warn(A-48-44-70)'
Is := 'lib'

TEST_PKGS := 'bap,z3,bap_wp,ounit2,re,str,core_unix'
TEST_TAG := 'warn(A-48-44-70),debug,thread'
TEST_Is := 'lib,tests/test_libs'

TEST_Is_UNIT := $(TEST_Is)',tests/unit'
TEST_Is_INTEGRATION := $(TEST_Is)',tests/integration'

BUILD := $(PASS_NAME).plugin
SRC_FILES := $(wildcard **/*.ml) $(wildcard **/*.mli)

LIB_SRC_FILES := $(wildcard ../lib/bap_wp/src/*.ml) $(wildcard ../lib/bap_wp/src/*.mli)

TRACK_LIB:= _build/TRACK_LIB

#####################################################
# DEFAULT
#####################################################
Expand All @@ -37,35 +18,22 @@ all: install
# CLEAN
#####################################################

clean: uninstall
bapbuild -clean


####################################################
# REBUILD ON LIB CHANGE
####################################################

$(TRACK_LIB): $(LIB_SRC_FILES)
bapbuild -clean
mkdir _build
touch $(TRACK_LIB)
clean:
dune clean

#####################################################
# BUILD
#####################################################

build: $(BUILD)

$(BUILD): $(SRC_FILES) $(TRACK_LIB)
bapbuild -use-ocamlfind -pkgs $(PKGS) -tag $(TAG) -I $(Is) $(PASS_NAME).plugin
build:
dune build -p wp @install

#####################################################
# INSTALL
#####################################################

install: $(BUILD) $(VERIFIER_INSTALL_PATH)
bapbundle update -desc 'Computes the weakest precondition of a subroutine given a postcondition.' $(PASS_NAME).plugin
bapbundle install $(PASS_NAME).plugin
install: build $(VERIFIER_INSTALL_PATH)
dune install

$(VERIFIER_INSTALL_PATH): $(VERIFIER_LOCAL)
cp $(VERIFIER_LOCAL) $(VERIFIER_INSTALL_PATH)
Expand All @@ -76,7 +44,7 @@ uninstall.verifier:

.PHONY: uninstall
uninstall: uninstall.verifier
bapbundle remove $(PASS_NAME).plugin
dune uninstall

.PHONY: reinstall
reinstall: uninstall reinstall
Expand All @@ -97,15 +65,8 @@ test: test.unit

.PHONY: test.unit
test.unit: install
ocamlbuild -r -use-ocamlfind \
-pkgs $(TEST_PKGS) \
-tag $(TEST_TAG) -Is $(TEST_Is_UNIT) test.native
./test.native
dune runtest tests/unit

.PHONY: test.integration
test.integration: install
ocamlbuild -r -use-ocamlfind \
-pkgs $(TEST_PKGS) \
-tag $(TEST_TAG) \
-tag $(TEST_TAG) -Is $(TEST_Is_INTEGRATION) test.native
./test.native
dune runtest tests/integration
3 changes: 3 additions & 0 deletions wp/plugin/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 3.6)
(using dune_site 0.1)
(name wp)
11 changes: 11 additions & 0 deletions wp/plugin/src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(library
(name wp_plugin)
(public_name wp.plugin)
(libraries z3 bap_wp re str)
(preprocess (pps ppx_bin_prot)))

(plugin
(name wp)
(package wp)
(libraries wp.plugin)
(site (bap-common plugins)))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions wp/plugin/wp.ml → wp/plugin/src/wp_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,9 @@ let callback

let () =
Cmd.declare name grammar callback ~doc

let () =
let doc =
"Computes the weakest precondition of a \
subroutine given a postcondition." in
Extension.declare ~doc @@ fun _ -> Ok ()
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions wp/plugin/tests/integration/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(test
(name test)
(libraries wp.test))
2 changes: 1 addition & 1 deletion wp/plugin/tests/integration/test_wp_integration.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open OUnitTest
open Test_wp_utils
open Test_lib.Test_wp_utils

let integration_tests = List.append [

Expand Down
4 changes: 4 additions & 0 deletions wp/plugin/tests/test_libs/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name test_lib)
(public_name wp.test)
(libraries z3 ounit2 bap_wp re str core_unix))
4 changes: 2 additions & 2 deletions wp/plugin/tests/test_libs/test_wp_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module IntSet = Set.Make(Int)

(* To run these tests: `make test` or `make test.integration` in wp directory *)

let bin_dir = "../resources/sample_binaries"
let bin_dir = "../../../../../resources/sample_binaries"

let timeout_msg = "Test times out!"

Expand Down Expand Up @@ -292,7 +292,7 @@ let test_plugin
~foutput:(fun res -> check_result res reg_list checker)
~backtrace:true
~chdir:target
~ctxt:ctxt
~ctxt
in
test_case ~length test

Expand Down
3 changes: 3 additions & 0 deletions wp/plugin/tests/unit/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(test
(name test)
(libraries wp.test))
2 changes: 1 addition & 1 deletion wp/plugin/tests/unit/test_wp_unit.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open OUnitTest
open Test_wp_utils
open Test_lib.Test_wp_utils

let unit_tests = [

Expand Down
25 changes: 25 additions & 0 deletions wp/plugin/wp.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
opam-version: "2.0"
name: "wp"
version: "0.1"
synopsis: "A weakest-precondition analysis plugin"
description: """
A weakest-precondition analysis plugin for use with BAP.
"""
maintainer: "Draper Laboratory"
authors: [
"Chloe Fortuna <[email protected]>"
"JT Paasch <[email protected]>"
"Philip Zucker <[email protected]>"
"Benjamin Mourad <[email protected]>"
]
license: "MIT"
homepage: "https://github.com/draperlaboratory/cbat_tools"
bug-reports: "https://github.com/draperlaboratory/cbat_tools"
dev-repo: "git+https://github.com/draperlaboratory/cbat_tools"
depends: [
"bap" {>= "2.4.0"}
"core" {>= "v0.15.0"}
"z3" {>= "4.8.14"}
"ounit2" {>= "2.2.3"}
"re" {>= "1.9.0"}
]