Compare commits
No commits in common. "d3a2124f8b65a82e61b4574665872d0ef94b8bb5" and "4c37f4872d709a04c5b5d0cc7aa342eae26c8643" have entirely different histories.
d3a2124f8b
...
4c37f4872d
26 changed files with 0 additions and 175 deletions
|
|
@ -10,20 +10,6 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Indique si une transaction est actuellement active.
|
|
||||||
*
|
|
||||||
* Cette fonction ne modifie ni la connexion ni son erreur courante.
|
|
||||||
*
|
|
||||||
* @param database Connexion à inspecter.
|
|
||||||
*
|
|
||||||
* @return true lorsqu’une transaction est active, sinon false.
|
|
||||||
* Une connexion NULL retourne false.
|
|
||||||
*/
|
|
||||||
bool database_transaction_is_active(
|
|
||||||
const Database *database
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Démarre une transaction d'écriture immédiate.
|
* @brief Démarre une transaction d'écriture immédiate.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
BIN
labfy-investigation
Executable file
BIN
labfy-investigation
Executable file
Binary file not shown.
|
|
@ -88,20 +88,6 @@ static bool database_transaction_execute(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool database_transaction_is_active(
|
|
||||||
const Database *database
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (database == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return database_get_transaction_active(
|
|
||||||
database
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool database_transaction_begin(
|
bool database_transaction_begin(
|
||||||
Database *database
|
Database *database
|
||||||
)
|
)
|
||||||
|
|
|
||||||
BIN
tests/test_background_task
Executable file
BIN
tests/test_background_task
Executable file
Binary file not shown.
BIN
tests/test_database
Executable file
BIN
tests/test_database
Executable file
Binary file not shown.
BIN
tests/test_error
Executable file
BIN
tests/test_error
Executable file
Binary file not shown.
BIN
tests/test_evidence_copy
Executable file
BIN
tests/test_evidence_copy
Executable file
Binary file not shown.
BIN
tests/test_evidence_dao
Executable file
BIN
tests/test_evidence_dao
Executable file
Binary file not shown.
BIN
tests/test_evidence_record
Executable file
BIN
tests/test_evidence_record
Executable file
Binary file not shown.
BIN
tests/test_file_hash
Executable file
BIN
tests/test_file_hash
Executable file
Binary file not shown.
BIN
tests/test_investigation_dao
Executable file
BIN
tests/test_investigation_dao
Executable file
Binary file not shown.
BIN
tests/test_investigation_node
Executable file
BIN
tests/test_investigation_node
Executable file
Binary file not shown.
BIN
tests/test_investigation_project
Executable file
BIN
tests/test_investigation_project
Executable file
Binary file not shown.
BIN
tests/test_investigation_record
Executable file
BIN
tests/test_investigation_record
Executable file
Binary file not shown.
BIN
tests/test_investigation_session
Executable file
BIN
tests/test_investigation_session
Executable file
Binary file not shown.
BIN
tests/test_investigation_tree_builder
Executable file
BIN
tests/test_investigation_tree_builder
Executable file
Binary file not shown.
BIN
tests/test_investigation_tree_model
Executable file
BIN
tests/test_investigation_tree_model
Executable file
Binary file not shown.
BIN
tests/test_statement
Executable file
BIN
tests/test_statement
Executable file
Binary file not shown.
BIN
tests/test_task_manager
Executable file
BIN
tests/test_task_manager
Executable file
Binary file not shown.
BIN
tests/test_tool_catalog
Executable file
BIN
tests/test_tool_catalog
Executable file
Binary file not shown.
BIN
tests/test_tool_initializer
Executable file
BIN
tests/test_tool_initializer
Executable file
Binary file not shown.
BIN
tests/test_tool_process
Executable file
BIN
tests/test_tool_process
Executable file
Binary file not shown.
BIN
tests/test_tool_registry
Executable file
BIN
tests/test_tool_registry
Executable file
Binary file not shown.
BIN
tests/test_tool_task
Executable file
BIN
tests/test_tool_task
Executable file
Binary file not shown.
BIN
tests/test_transaction
Executable file
BIN
tests/test_transaction
Executable file
Binary file not shown.
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Crée la table utilisée par les tests.
|
* @brief Crée la table utilisée par les tests.
|
||||||
|
|
@ -307,158 +306,12 @@ static void test_transaction_error_state(void)
|
||||||
database_close(database);
|
database_close(database);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Vérifie l’exposition publique de l’état de transaction.
|
|
||||||
*/
|
|
||||||
static void test_transaction_active_state(void)
|
|
||||||
{
|
|
||||||
Database *database = NULL;
|
|
||||||
|
|
||||||
const char *error_message = NULL;
|
|
||||||
|
|
||||||
database =
|
|
||||||
database_open(
|
|
||||||
":memory:"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(database != NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Une connexion nouvelle ne possède aucune transaction active.
|
|
||||||
*/
|
|
||||||
assert(
|
|
||||||
!database_transaction_is_active(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Une connexion NULL est considérée comme inactive.
|
|
||||||
*/
|
|
||||||
assert(
|
|
||||||
!database_transaction_is_active(
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* La consultation de l’état ne doit pas modifier l’erreur courante.
|
|
||||||
*/
|
|
||||||
database_error_set(
|
|
||||||
database,
|
|
||||||
DATABASE_ERROR_INVALID_ARGUMENT,
|
|
||||||
"erreur témoin"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
!database_transaction_is_active(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
database_error_get_code(
|
|
||||||
database
|
|
||||||
) ==
|
|
||||||
DATABASE_ERROR_INVALID_ARGUMENT
|
|
||||||
);
|
|
||||||
|
|
||||||
error_message =
|
|
||||||
database_error_get_message(
|
|
||||||
database
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(error_message != NULL);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
strcmp(
|
|
||||||
error_message,
|
|
||||||
"erreur témoin"
|
|
||||||
) == 0
|
|
||||||
);
|
|
||||||
|
|
||||||
database_error_clear(
|
|
||||||
database
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* L’état devient actif après BEGIN.
|
|
||||||
*/
|
|
||||||
assert(
|
|
||||||
database_transaction_begin(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
database_transaction_is_active(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Un simple contrôle ne doit pas terminer la transaction.
|
|
||||||
*/
|
|
||||||
assert(
|
|
||||||
database_transaction_is_active(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* L’état redevient inactif après COMMIT.
|
|
||||||
*/
|
|
||||||
assert(
|
|
||||||
database_transaction_commit(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
!database_transaction_is_active(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Même vérification avec un ROLLBACK.
|
|
||||||
*/
|
|
||||||
assert(
|
|
||||||
database_transaction_begin(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
database_transaction_is_active(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
database_transaction_rollback(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
assert(
|
|
||||||
!database_transaction_is_active(
|
|
||||||
database
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
database_close(
|
|
||||||
database
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
test_transaction_commit();
|
test_transaction_commit();
|
||||||
test_transaction_rollback();
|
test_transaction_rollback();
|
||||||
test_invalid_transaction_states();
|
test_invalid_transaction_states();
|
||||||
test_transaction_error_state();
|
test_transaction_error_state();
|
||||||
test_transaction_active_state();
|
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
"DatabaseTransaction : tous les tests sont valides.\n"
|
"DatabaseTransaction : tous les tests sont valides.\n"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue