Bonjour,

Je cherche � faire une couverture de tests sur cette fonction-ci :

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "GsbMemory.hpp"
 
GsbAccessError::GsbAccessErrorEnum GsbMemory::copy(void *destination, const void *source, unsigned int size) {
 
	GsbAccessError::GsbAccessErrorEnum res = GsbAccessError::ACCESS_SUCCESSFUL;
 
	if (destination == 0 || source == 0) {
		res = GsbAccessError::NULL_POINTER;
	}
 
	else {
 
		// Size is not a multiple of 4 and source and destination addresses are not aligned with 32 bits
		// -> copy byte by byte
 
		if (((unsigned int) source | (unsigned int) destination | size) & (sizeof(unsigned int) - 1)){
 
			unsigned char * pS = (unsigned char *) source;
			unsigned char * pD = (unsigned char *) destination;
			unsigned char * pE = (unsigned char *) (((unsigned char *) source) + size);
 
			while (pS != pE) {
				*(pD++) = *(pS++);
			}
		}
 
		// Size is a multiple of 4 and source and destination addresses are aligned with 32 bits
		// -> copy 4 bytes by 4 bytes
 
		else {
 
			if ((size >> 2) & 1) {
 
				unsigned int *pS = (unsigned int *) source;
				unsigned int *pD = (unsigned int *) destination;
				unsigned int *pE = (unsigned int *) (unsigned char *) (((unsigned char *)source) + size);
 
				while (pS != pE) {
					*(pD++) = *(pS++);
				}
 
			}
 
			// Size is a multiple of 8 and source and destination addresses are aligned with 32 bits
			// -> copy 8 bytes by 8 bytes
 
			else {
 
				long long * pS = (long long *) source;
				long long * pD = (long long *) destination;
				long long * pE = (long long *) (unsigned char *) (((unsigned char *)source) + size);
 
				while (pS != pE) {
					*(pD++) = *(pS++);
				}
			}
		}
	}
 
	return res;
}
Sachant que j'ai d�j� effectu� des tests unitaires avec CxxTest (et qu'ils fonctionnent), je voulais optimiser la chose en utilisant gcov.

J'ai cr�� un .bat dans mon projet dans lequel j'ai mis ceci :

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
echo script_genGcov.bat
 
sparc-threadx-gcov.exe -fprofile-arcs -ftest-coverage C:\home\cgarcia\workspace\GericosBlocks\sources\gericos\blocks\memory\GsbMemoryTest.cpp
 
sparc-threadx-gcov.exe C:\home\cgarcia\workspace\GericosBlocks\sources\gericos\blocks\memory\GsbMemoryTest.cpp
 
pause
Je suis all�e voir dans la documentation et j'ai recopi� les m�mes options mais apparemment cela ne fonctionne pas tr�s bien -.-

Voici ce que j'obtiens lorsque je lance le .bat :

Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
C:\opt\eclipse>echo script_genGcov.bat
script_genGcov.bat
 
C:\opt\eclipse>sparc-threadx-gcov.exe -fprofile-arcs -ftest-coverage C:\home\cgarcia\workspace\GericosBlocks\sources\gericos\block
s\memory\GsbMemoryTest.cpp
sparc-threadx-gcov.exe: invalid option -- r
Usage: gcov [OPTION]... SOURCEFILE
 
Print code coverage information.
 
  -h, --help                      Print this help, then exit
  -v, --version                   Print version number, then exit
  -a, --all-blocks                Show information for every basic block
  -b, --branch-probabilities      Include branch probabilities in output
  -c, --branch-counts             Given counts of branches taken
                                    rather than percentages
  -n, --no-output                 Do not create an output file
  -l, --long-file-names           Use long output file names for included
                                    source files
  -f, --function-summaries        Output summaries for each function
  -o, --object-directory DIR|FILE Search for object files in DIR or called FILE
  -p, --preserve-paths            Preserve all pathname components
  -u, --unconditional-branches    Show unconditional branch counts too
 
For bug reporting instructions, please see:
<URL:http://gcc.gnu.org/bugs.html>.
 
C:\opt\eclipse>sparc-threadx-gcov.exe C:\home\cgarcia\workspace\GericosBlocks\sources\gericos\blocks\memory\GsbMemoryTest.cpp
C:\home\cgarcia\workspace\GericosBlocks\sources\gericos\blocks\memory\GsbMemoryTest.gcno:cannot open graph file
 
C:\opt\eclipse>pause
Appuyez sur une touche pour continuer...
Ces lignes l� me font douter :
- invalid option -- r (je n'en ai pas mis, si ?)
- GsbMemoryTest.gcno:cannot open graph file (je ne vois pas le fichier .gcno, m�me apr�s actualisation dans mon projet et je ne vois pas ce qui ne va pas quant � l'ouverture du fichier)

Peut-�tre ai-je mal compris une �tape dans la mise en place ?

Merci par avance pour votre aide