Author: enrico
Date: Mon Oct 26 18:39:12 2015
New Revision: 251368

URL: http://llvm.org/viewvc/llvm-project?rev=251368&view=rev
Log:
Change TestTypeCompletion to not rely on std::string

On some combination of platform and c++ library, this dependency was causing 
the test to fail for reasons tangential to its real objective


Modified:
    lldb/trunk/test/functionalities/type_completion/TestTypeCompletion.py
    lldb/trunk/test/functionalities/type_completion/main.cpp

Modified: lldb/trunk/test/functionalities/type_completion/TestTypeCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/type_completion/TestTypeCompletion.py?rev=251368&r1=251367&r2=251368&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/type_completion/TestTypeCompletion.py 
(original)
+++ lldb/trunk/test/functionalities/type_completion/TestTypeCompletion.py Mon 
Oct 26 18:39:12 2015
@@ -73,14 +73,10 @@ class TypeCompletionTestCase(TestBase):
         self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be 
valid')
         self.assertTrue(name_address_type.IsTypeComplete(), 'NameAndAddress 
should now be complete')
         field0 = name_address_type.GetFieldAtIndex(0)
-        if self.TraceOn():
-             print('field0: ' + str(field0))
         self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be 
valid')
         string = field0.GetType().GetPointeeType()
-        if self.TraceOn():
-             print('string: ' + str(string))
-        self.assertTrue(string.IsValid(), 'std::string should be valid')
-        self.assertFalse(string.IsTypeComplete(), 'std::string complete but it 
should not be')
+        self.assertTrue(string.IsValid(), 'CustomString should be valid')
+        self.assertFalse(string.IsTypeComplete(), 'CustomString complete but 
it should not be')
 
         self.runCmd("continue")
 
@@ -91,17 +87,13 @@ class TypeCompletionTestCase(TestBase):
         self.assertTrue(name_address_type.IsValid(), 'NameAndAddress should be 
valid')
         self.assertTrue(name_address_type.IsTypeComplete(), 'NameAndAddress 
should now be complete')
         field0 = name_address_type.GetFieldAtIndex(0)
-        if self.TraceOn():
-             print('field0: ' + str(field0))
         self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be 
valid')
         string = field0.GetType().GetPointeeType()
-        if self.TraceOn():
-             print('string: ' + str(string))
-        self.assertTrue(string.IsValid(), 'std::string should be valid')
-        self.assertFalse(string.IsTypeComplete(), 'std::string complete but it 
should not be')
+        self.assertTrue(string.IsValid(), 'CustomString should be valid')
+        self.assertFalse(string.IsTypeComplete(), 'CustomString complete but 
it should not be')
 
         self.runCmd('type category enable -l c++', check=False)
-        self.runCmd('frame variable guy --show-types')
+        self.runCmd('frame variable guy --show-types --ptr-depth=1')
 
         p_vector = 
self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame().FindVariable('p')
         p_type = p_vector.GetType()
@@ -112,5 +104,5 @@ class TypeCompletionTestCase(TestBase):
         field0 = name_address_type.GetFieldAtIndex(0)
         self.assertTrue(field0.IsValid(), 'NameAndAddress::m_name should be 
valid')
         string = field0.GetType().GetPointeeType()
-        self.assertTrue(string.IsValid(), 'std::string should be valid')
-        self.assertTrue(string.IsTypeComplete(), 'std::string should now be 
complete')
+        self.assertTrue(string.IsValid(), 'CustomString should be valid')
+        self.assertTrue(string.IsTypeComplete(), 'CustomString should now be 
complete')

Modified: lldb/trunk/test/functionalities/type_completion/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/type_completion/main.cpp?rev=251368&r1=251367&r2=251368&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/type_completion/main.cpp (original)
+++ lldb/trunk/test/functionalities/type_completion/main.cpp Mon Oct 26 
18:39:12 2015
@@ -7,16 +7,45 @@
 //
 
//===----------------------------------------------------------------------===//
 
-#include <string>
+#include <string.h>
 #include <vector>
 #include <iostream>
 
+class CustomString
+{
+public:
+  CustomString (const char* buffer) :
+    m_buffer(nullptr)
+  {
+    if (buffer)
+    {
+      auto l = strlen(buffer);
+      m_buffer = new char[1 + l];
+      strcpy(m_buffer, buffer);
+    }
+  }
+  
+  ~CustomString ()
+  {
+    delete[] m_buffer;
+  }
+  
+  const char*
+  GetBuffer ()
+  {
+    return m_buffer;
+  }
+  
+private:
+  char *m_buffer;
+};
+
 class NameAndAddress
        {
        public:
-               std::string& GetName() { return *m_name; }
-               std::string& GetAddress() { return *m_address; }
-               NameAndAddress(const char* N, const char* A) : m_name(new 
std::string(N)), m_address(new std::string(A))
+               CustomString& GetName() { return *m_name; }
+               CustomString& GetAddress() { return *m_address; }
+               NameAndAddress(const char* N, const char* A) : m_name(new 
CustomString(N)), m_address(new CustomString(A))
                {
                }
                ~NameAndAddress()
@@ -24,8 +53,8 @@ class NameAndAddress
                }
                
        private:
-               std::string* m_name;
-               std::string* m_address;
+               CustomString* m_name;
+               CustomString* m_address;
 };
 
 typedef std::vector<NameAndAddress> People;
@@ -43,7 +72,7 @@ int main (int argc, const char * argv[])
        for (int j = 0; j<p.size(); j++)
        {
                NameAndAddress guy = p[j];
-               std::cout << "Person " << j << " is named " << guy.GetName() << 
" and lives at " << guy.GetAddress() << std::endl; // Set break point at this 
line.
+               std::cout << "Person " << j << " is named " << 
guy.GetName().GetBuffer() << " and lives at " << guy.GetAddress().GetBuffer() 
<< std::endl; // Set break point at this line.
        }
 
        return 0;


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to