Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not recognize functions of SUT #4

Open
magsilva opened this issue Mar 21, 2016 · 5 comments
Open

Do not recognize functions of SUT #4

magsilva opened this issue Mar 21, 2016 · 5 comments
Labels

Comments

@magsilva
Copy link
Owner

Proteum fails to recognize functions within a software under testing. That's quite frequent. For instance, if a function makes use of 'sprintf', it is not recognized by Proteum. See Righetto's report:

"""
a ferramenta não consegue reconhecer todas as funções do código; não sei ao certo o porque isso acontece, mas fiz alguns testes e utilizar a função "sprintf" faz com que a função não seja reconhecida, ou utilizar acesso de vetor ou criação estática em uma função diferente da main. Porém, esta ultima afirmação eu não tenho total certeza porque em programas como QuadTree existe uma sctruct com declaração estática de vetor e funciona.
"""

@magsilva
Copy link
Owner Author

Example:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

long int getPrevNumber(long int x) {
    char buffer[1024];
    sprintf(buffer,"%ld",x);
    int count[16] = {};
    int sizeBuffer = strlen(buffer);
    long int prev = 0;
    int i=0;
    for(i=0;i<sizeBuffer;i++)  {
        int c=-1;
        int j=9;
        for(j=9;j>=0;j--)   {
            if(count[j] == 2)
                continue;
            count[j]++;
            int tlen = 0;
            long int mn = j;
            long int ten = 10;
            int k=0;
            for(k=0;k<10;k++) {
                int l=count[k];
                for (l=count[k];l<2;l++) {
                    if (tlen < sizeBuffer-i-1) {
                        mn = mn*10+k;
                        tlen++;
                        ten *= 10;
                    }
                }
            }
            count[j]--;
            if (prev*ten + mn <= x)  {
                c = j;
                break;
            }
        }
        if (c != -1) {
            prev = prev*10+c; 
            count[c]++;
        }
    }
    return prev;
}

int main() {
    long int x;
    while(scanf("%ld",&x) != EOF)
        printf("%ld\n",getPrevNumber(x));
    return 0;
}

@magsilva
Copy link
Owner Author

Another example. In this one it fails to parse the functions when calling the function long2char within isPrime:

long int isPrime(long int N)
{
    long int* Prime = (long int*)calloc(1,sizeof(long int));
    long int i;
    long int count[16] = {0,0,0};
    long2char(N); //Sem esta linha, a proteum reconhece todas as funções.

@magsilva
Copy link
Owner Author

Parsing of array declarations is also somewhat faulty. Empty array declaration does not work (char b[2] = {}), but this works: char b[2] = {0,0};

@magsilva
Copy link
Owner Author

Parser also seems buggy when handling spaces:

char int2char( int i )
{ 
    if ( i < 0 ) { return '~'; }
    if ( i < 10 ) { return '0' + i; }
    if ( i < 36 ) { return 'a' + i - 10; }
    if ( i < 62 ) { return 'A' + i - 36; }

    return '$'; 
}

@magsilva
Copy link
Owner Author

Full examples.
examples.zip

@magsilva magsilva added the bug label Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant