Skip to content

Commit

Permalink
Update file structure for proofs (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
feliperodri authored and danielsn committed Mar 15, 2019
1 parent 56e3549 commit a09c186
Show file tree
Hide file tree
Showing 35 changed files with 287 additions and 1,054 deletions.
4 changes: 0 additions & 4 deletions .cbmc-batch/config.h

This file was deleted.

File renamed without changes.
36 changes: 36 additions & 0 deletions .cbmc-batch/include/proof_helpers/make_common_data_structures.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is
* located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <aws/common/array_list.h>
#include <aws/common/common.h>

#include "nondet.h"

#include <stdlib.h>

#define MAX_INITIAL_ITEM_ALLOCATION 2
#define MAX_ITEM_SIZE 2
#define MAX_STR_LEN 32
#define MAX_BUF_LEN 32

#define ASSUME_VALID_MEMORY(ptr) ptr = malloc(sizeof(*(ptr)))
#define ASSUME_VALID_MEMORY_COUNT(ptr, count) ptr = malloc(sizeof(*(ptr)) * (count))
#define ASSUME_DEFAULT_ALLOCATOR(allocator) allocator = aws_default_allocator()
#define ASSUME_ARBITRARY_ARRAY_LIST(list, item_count, item_size) \
list = make_arbitrary_array_list((item_count), (item_size))

struct aws_array_list *make_arbitrary_array_list(size_t item_count, size_t item_size);
29 changes: 29 additions & 0 deletions .cbmc-batch/include/proof_helpers/nondet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is
* located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

/**
* Non-determinstic functions used in CBMC proofs
*/
size_t nondet_size_t();
int nondet_int();
uint8_t nondet_uint8_t();
bool nondet_bool();
void *nondet_voidp();
2 changes: 1 addition & 1 deletion .cbmc-batch/jobs/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ GOTO_INSTRUMENT ?= goto-instrument
HELPERDIR ?= $(SRCDIR)/.cbmc-batch

INC += \
-I$(HELPERDIR)/. \
-I$(HELPERDIR)/include/ \
-I$(SRCDIR)/include/

SIMPLIFY ?= 0
Expand Down
5 changes: 3 additions & 2 deletions .cbmc-batch/jobs/aws_add_size_checked/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/common.c

ENTRY = aws_add_size_checked_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/math.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

/**
* Adds a + b and returns the result in *r. If the result
Expand Down
5 changes: 3 additions & 2 deletions .cbmc-batch/jobs/aws_add_size_saturating/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/common.c

ENTRY = aws_add_size_saturating_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/math.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

/**
* Adds a + b. If the result overflows returns 2^64 - 1.
Expand Down
8 changes: 4 additions & 4 deletions .cbmc-batch/jobs/aws_array_list_init_dynamic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/byte_buf.c \
$(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/common.c

ENTRY = aws_array_list_init_dynamic_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/array_list.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

void aws_array_list_init_dynamic_harness() {
struct aws_array_list *list;
Expand Down
8 changes: 4 additions & 4 deletions .cbmc-batch/jobs/aws_array_list_init_static/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/byte_buf.c \
$(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/common.c

ENTRY = aws_array_list_init_static_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/array_list.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

void aws_array_list_init_static_harness() {
struct aws_array_list *list;
Expand Down
16 changes: 8 additions & 8 deletions .cbmc-batch/jobs/aws_array_list_push_back/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
###########
#NOTE: If we don't use the unwindset, leave it empty
CBMC_UNWINDSET = --unwindset
CBMC_UNWINDSET += __builtin___memcpy_chk.0:33,
CBMC_UNWINDSET += __builtin___memcpy_chk.0:5,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)aws_mem_release:1,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)memcpy.0:33,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)strlen.0:33
CBMC_UNWINDSET := $(CBMC_UNWINDSET)memcpy.0:5,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)strlen.0:5

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/byte_buf.c \
$(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c \
$(HELPERDIR)/patches/string.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(HELPERDIR)/stubs/memcpy_override.c \
$(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/common.c

ENTRY = aws_array_list_push_back_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/array_list.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

void aws_array_list_push_back_harness() {
size_t item_count = nondet_size_t();
Expand Down
2 changes: 1 addition & 1 deletion .cbmc-batch/jobs/aws_array_list_push_back/cbmc-batch.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jobos: ubuntu16
cbmcflags: "--bounds-check;--pointer-check;--function;aws_array_list_push_back_harness;--unwindset;strlen.0:33,memcpy.0:33,__builtin___memcpy_chk.0:33,aws_mem_release:1;--unwinding-assertions"
cbmcflags: "--bounds-check;--pointer-check;--function;aws_array_list_push_back_harness;--unwindset;strlen.0:5,memcpy.0:5,__builtin___memcpy_chk.0:5,aws_mem_release:1;--unwinding-assertions"
goto: aws_array_list_push_back_harness.goto
expected: "SUCCESSFUL"
16 changes: 8 additions & 8 deletions .cbmc-batch/jobs/aws_array_list_set_at/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
###########
#NOTE: If we don't use the unwindset, leave it empty
CBMC_UNWINDSET = --unwindset
CBMC_UNWINDSET += __builtin___memcpy_chk.0:33,
CBMC_UNWINDSET += __builtin___memcpy_chk.0:5,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)aws_mem_release:1,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)memcpy.0:33,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)strlen.0:33
CBMC_UNWINDSET := $(CBMC_UNWINDSET)memcpy.0:5,
CBMC_UNWINDSET := $(CBMC_UNWINDSET)strlen.0:5

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/byte_buf.c \
$(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c \
$(HELPERDIR)/patches/string.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(HELPERDIR)/stubs/memcpy_override.c \
$(SRCDIR)/source/array_list.c \
$(SRCDIR)/source/common.c

ENTRY = aws_array_list_set_at_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/array_list.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

void aws_array_list_set_at_harness() {
size_t initial_item_allocation = nondet_size_t();
Expand Down
2 changes: 1 addition & 1 deletion .cbmc-batch/jobs/aws_array_list_set_at/cbmc-batch.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jobos: ubuntu16
cbmcflags: "--bounds-check;--pointer-check;--function;aws_array_list_set_at_harness;--unwindset;strlen.0:33,memcpy.0:33,__builtin___memcpy_chk.0:33,aws_mem_release:1;--unwinding-assertions"
cbmcflags: "--bounds-check;--pointer-check;--function;aws_array_list_set_at_harness;--unwindset;strlen.0:5,memcpy.0:5,__builtin___memcpy_chk.0:5,aws_mem_release:1;--unwinding-assertions"
goto: aws_array_list_set_at_harness.goto
expected: "SUCCESSFUL"
8 changes: 4 additions & 4 deletions .cbmc-batch/jobs/aws_byte_buf_append/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ CBMC_UNWINDSET := $(CBMC_UNWINDSET)memcpy.0:33

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/array_list.c \
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(HELPERDIR)/stubs/memcpy_override.c \
$(SRCDIR)/source/byte_buf.c \
$(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c \
$(HELPERDIR)/patches/string.c
$(SRCDIR)/source/common.c

ENTRY = aws_byte_buf_append_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/byte_buf.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

void aws_byte_buf_append_harness() {
size_t len1 = nondet_size_t();
Expand Down
6 changes: 3 additions & 3 deletions .cbmc-batch/jobs/aws_byte_buf_from_c_str/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ CBMC_UNWINDSET += strlen.0:33

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/array_list.c \
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/byte_buf.c \
$(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
$(SRCDIR)/source/common.c

ENTRY = aws_byte_buf_from_c_str_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/byte_buf.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

void aws_byte_buf_from_c_str_harness() {
size_t len = nondet_size_t();
Expand Down
6 changes: 3 additions & 3 deletions .cbmc-batch/jobs/aws_byte_buf_init/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/array_list.c \
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/byte_buf.c \
$(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
$(SRCDIR)/source/common.c

ENTRY = aws_byte_buf_init_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/byte_buf.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

void aws_byte_buf_init_harness() {
struct aws_allocator *allocator;
Expand Down
7 changes: 4 additions & 3 deletions .cbmc-batch/jobs/aws_mul_size_checked/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
#NOTE: If we don't use the unwindset, leave it empty
#CBMC_UNWINDSET = --unwindset

CBMCFLAGS +=
CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/common.c

ENTRY = aws_mul_size_checked_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/math.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

/**
* Multiplies a * b and returns the result in *r. If the result
Expand Down
5 changes: 3 additions & 2 deletions .cbmc-batch/jobs/aws_mul_size_saturating/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

CBMCFLAGS +=

DEPENDENCIES = $(SRCDIR)/source/common.c \
$(SRCDIR)/source/error.c
DEPENDENCIES = $(HELPERDIR)/source/make_common_data_structures.c \
$(HELPERDIR)/stubs/error.c \
$(SRCDIR)/source/common.c

ENTRY = aws_mul_size_saturating_harness
###########
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <aws/common/math.h>
#include <proof_helpers.h>
#include <proof_helpers/make_common_data_structures.h>

/**
* Multiplies a * b. If the result overflows, returns 2^64 - 1.
Expand Down
Loading

0 comments on commit a09c186

Please sign in to comment.