Reading text from serial and compare the input always fails

Not exactly, but it depends on your "serial protocol". Are all the commands the same size in terms of characters ora can be variable lengths? Do you use a "line terminator" character?
Based on your description, the answer is "no, the commands are variable and use line terminating characters \r\n sent from the Serial monitor input".
To make things easier, my advise is to use single-character commands, for example just "I" (followed by "\r\n" automatically added) for Info request, or "T" for test.

But if you want to keep your syntax, your sample code to receive a command and compare with some fixed command strings could be something like this one:

#define MAXBUF 32
char inputbuf[MAXBUF];
int counter = 0;
bool cmdReceived = false;

// Fixed commands list (note 
#define CMD_ID "ID?"
#define CMD_TEST "TEST"

void setup() {
  Serial.begin(9600); 
}

void bufReset() {
  inputbuf[0]='\0';
  counter=0;
  cmdReceived = false;
}

void bufAdd(char c) {
  // Ignore '\r' and '\n' and avoid buffer overflow
  if (c != '\r' && c != '\n' && counter+1 < MAXBUF) {
    // Convert to uppercase if needed
    if (c >= 'a' && < <= 'z') c = c - 'a' + 'A';
    inputBuf[counter++] = c;
    inputBuf[counter] = '\0';
  }
  // If LF has been received, the command is complete
  cmdReceived  = (c == '\n');
}
void loop() {
  if (Serial.available()>0) {
    bufAdd(Serial.read());
  }
  if (cmdReceived) {
    Serial.print("Received: ");Serial.println(inputbuf);
    if (strcmp(inputbuf,CMD_ID)==0)
    {
      Serial.println("The ID is 1");
    }
    else if (strcmp(inputbuf,CMD_TEST)==0)
    {
      Serial.println("Test OK");
    }
    else
      Serial.println("Unkown command");

    // Reset buffer
    bufReset();
  } 
}

Please note the changes I made, including "strcasecmp()" function to compare ignoring upper/lower case, and the usage of two useful functions for an easier handling of the buffer...