Skip to content

Commit

Permalink
Merge branch '1.0.x' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jun 18, 2021
2 parents 18cf127 + f3fb2e8 commit 295dfb9
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 56 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ jobs:
if [ "$TEST_MODE" = "coverage" ]; then
export CFLAGS="-fprofile-arcs -ftest-coverage"
fi
PKGS="libc6-dev-i386 gcc-multilib libsqlite3-dev"
if [ "$TEST_MODE" = "coverage" ]; then PKGS="$PKGS lcov"; fi
sudo apt-get update -qq
sudo apt-get install -qq libc6-dev-i386 gcc-multilib libsqlite3-dev
sudo apt-get install -qq $PKGS
if [ $TEST_MODE = "coverage" ]; then
pip install 'coverage<5' codecov
pip install 'coverage<5'
pip install -e ./reprozip -e ./reprounzip -e ./reprounzip-docker -e ./reprounzip-vagrant -e ./reprounzip-vistrails -e ./reprounzip-qt -e ./reprozip-jupyter
else
pip install ./reprozip ./reprounzip ./reprounzip-docker ./reprounzip-vagrant ./reprounzip-vistrails ./reprounzip-qt -e ./reprozip-jupyter
Expand Down Expand Up @@ -106,10 +108,10 @@ jobs:
# Python
if [ -f .coverage ]; then mv .coverage .coverage.orig; fi # FIXME: useless?
coverage combine
codecov
# C
# Find the coverage file (in distutils's build directory)
OBJDIR=$(dirname "$(find . -name pytracer.gcno | head -n 1)")
(cd reprozip/native && gcov -o ../../$OBJDIR *.c)
curl -s -o - https://codecov.io/bash | bash -
(cd reprozip/native && lcov --directory ../../$OBJDIR -c -o reprozip.lcov)
curl -s -o - https://codecov.io/bash | bash -s - -X gcov
40 changes: 24 additions & 16 deletions reprozip/native/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static sqlite3_uint64 gettime(void)
log_critical(0, "getting time failed (clock_gettime): %s",
strerror(errno));
exit(125);
/* LCOV_EXCL_END */
/* LCOV_EXCL_STOP */
}
timestamp = now.tv_sec;
timestamp *= 1000000000;
Expand Down Expand Up @@ -85,7 +85,7 @@ int db_init(const char *filename)
}
sqlite3_finalize(stmt_get_tables);
if(ret != SQLITE_DONE)
goto sqlerror;
goto sqlerror; /* LCOV_EXCL_LINE */
}

if(!tables_exist)
Expand Down Expand Up @@ -147,14 +147,18 @@ int db_init(const char *filename)
check(sqlite3_prepare_v2(db, sql, -1, &stmt_get_run_id, NULL));
if(sqlite3_step(stmt_get_run_id) != SQLITE_ROW)
{
/* LCOV_EXCL_START */
sqlite3_finalize(stmt_get_run_id);
goto sqlerror;
/* LCOV_EXCL_STOP */
}
run_id = sqlite3_column_int(stmt_get_run_id, 0);
if(sqlite3_step(stmt_get_run_id) != SQLITE_DONE)
{
/* LCOV_EXCL_START */
sqlite3_finalize(stmt_get_run_id);
goto sqlerror;
/* LCOV_EXCL_STOP */
}
sqlite3_finalize(stmt_get_run_id);
}
Expand Down Expand Up @@ -207,9 +211,11 @@ int db_init(const char *filename)

return 0;

/* LCOV_EXCL_START */
sqlerror:
log_critical(0, "sqlite3 error creating database: %s", sqlite3_errmsg(db));
return -1;
/* LCOV_EXCL_STOP */
}

int db_close(int rollback)
Expand All @@ -233,9 +239,11 @@ int db_close(int rollback)
run_id = -1;
return 0;

/* LCOV_EXCL_START */
sqlerror:
log_critical(0, "sqlite3 error on exit: %s", sqlite3_errmsg(db));
return -1;
/* LCOV_EXCL_STOP */
}

#define DB_NO_PARENT ((unsigned int)-2)
Expand All @@ -257,24 +265,24 @@ int db_add_process(unsigned int *id, unsigned int parent_id,
check(sqlite3_bind_int(stmt_insert_process, 4, is_thread?1:0));

if(sqlite3_step(stmt_insert_process) != SQLITE_DONE)
goto sqlerror;
goto sqlerror; /* LCOV_EXCL_LINE */
sqlite3_reset(stmt_insert_process);

/* Get id */
if(sqlite3_step(stmt_last_rowid) != SQLITE_ROW)
goto sqlerror;
goto sqlerror; /* LCOV_EXCL_LINE */
*id = sqlite3_column_int(stmt_last_rowid, 0);
if(sqlite3_step(stmt_last_rowid) != SQLITE_DONE)
goto sqlerror;
goto sqlerror; /* LCOV_EXCL_LINE */
sqlite3_reset(stmt_last_rowid);

return db_add_file_open(*id, working_dir, FILE_WDIR, 1);

sqlerror:
/* LCOV_EXCL_START : Insertions shouldn't fail */
sqlerror:
log_critical(0, "sqlite3 error inserting process: %s", sqlite3_errmsg(db));
return -1;
/* LCOV_EXCL_END */
/* LCOV_EXCL_STOP */
}

int db_add_first_process(unsigned int *id, const char *working_dir)
Expand All @@ -290,16 +298,16 @@ int db_add_exit(unsigned int id, int exitcode, int cpu_time)
check(sqlite3_bind_int(stmt_set_exitcode, 4, id));

if(sqlite3_step(stmt_set_exitcode) != SQLITE_DONE)
goto sqlerror;
goto sqlerror; /* LCOV_EXCL_LINE */
sqlite3_reset(stmt_set_exitcode);

return 0;

sqlerror:
/* LCOV_EXCL_START : Insertions shouldn't fail */
sqlerror:
log_critical(0, "sqlite3 error setting exitcode: %s", sqlite3_errmsg(db));
return -1;
/* LCOV_EXCL_END */
/* LCOV_EXCL_STOP */
}

int db_add_file_open(unsigned int process, const char *name,
Expand All @@ -314,15 +322,15 @@ int db_add_file_open(unsigned int process, const char *name,
check(sqlite3_bind_int(stmt_insert_file, 6, process));

if(sqlite3_step(stmt_insert_file) != SQLITE_DONE)
goto sqlerror;
goto sqlerror; /* LCOV_EXCL_LINE */
sqlite3_reset(stmt_insert_file);
return 0;

sqlerror:
/* LCOV_EXCL_START : Insertions shouldn't fail */
sqlerror:
log_critical(0, "sqlite3 error inserting file: %s", sqlite3_errmsg(db));
return -1;
/* LCOV_EXCL_END */
/* LCOV_EXCL_STOP */
}

static char *strarray2nulsep(const char *const *array, size_t *plen)
Expand Down Expand Up @@ -382,15 +390,15 @@ int db_add_exec(unsigned int process, const char *binary,
-1, SQLITE_TRANSIENT));

if(sqlite3_step(stmt_insert_exec) != SQLITE_DONE)
goto sqlerror;
goto sqlerror; /* LCOV_EXCL_LINE */
sqlite3_reset(stmt_insert_exec);
return 0;

sqlerror:
/* LCOV_EXCL_START : Insertions shouldn't fail */
sqlerror:
log_critical(0, "sqlite3 error inserting exec: %s", sqlite3_errmsg(db));
return -1;
/* LCOV_EXCL_END */
/* LCOV_EXCL_STOP */
}

int db_add_connection(unsigned int process, int inbound, const char *family,
Expand Down
2 changes: 1 addition & 1 deletion reprozip/native/ptrace_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static long tracee_getword(pid_t tid, const void *addr)
* execve(), which will dup arguments when entering the syscall */
log_error(tid, "tracee_getword() failed: %s", strerror(errno));
return 0;
/* LCOV_EXCL_END */
/* LCOV_EXCL_STOP */
}
return res;
}
Expand Down
4 changes: 4 additions & 0 deletions reprozip/native/pylog.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ int log_setup()
py_logger_log = PyObject_GetAttrString(py_logger, "log");
if(py_logger_log == NULL)
{
/* LCOV_EXCL_START : Logger objects always have a 'log' method */
Py_DECREF(py_logger);
py_logger = NULL;
return -1;
/* LCOV_EXCL_STOP */
}
}

Expand All @@ -56,8 +58,10 @@ int log_setup()
logging_level = PyLong_AsLong(level);
if(PyErr_Occurred())
{
/* LCOV_EXCL_START : Logger objects are reliable */
Py_DECREF(level);
return -1;
/* LCOV_EXCL_STOP */
}
Py_DECREF(level);
}
Expand Down
2 changes: 2 additions & 0 deletions reprozip/native/pytracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ static PyObject *pytracer_execute(PyObject *self, PyObject *args)

if(log_setup() != 0)
{
/* LCOV_EXCL_START : Can't fail unless Python is in a broken state */
PyErr_SetString(Err_Base, "Error occurred");
return NULL;
/* LCOV_EXCL_STOP */
}

/* Reads arguments */
Expand Down

0 comments on commit 295dfb9

Please sign in to comment.