Fix endianness part of QSysInfo::buildAbi() string

Both Q_LITTLE_ENDIAN and Q_BIG_ENDIAN macros are always defined
on all architectures. So, byte order detection results in
"little_endian" value for big endian systems. Test the system
endianness in a right way, according to Q_BYTE_ORDER macro
documentation.

Change-Id: I5523f90567e78d679a3ff2902a8f5377ed39ceb1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Alex Trotsenko 2014-09-02 17:55:56 +03:00
parent 59385ff2ca
commit e35841e374
2 changed files with 16 additions and 3 deletions

View File

@ -83,10 +83,10 @@
# define ARCH_PROCESSOR "unknown"
#endif
// endinanness
#if defined(Q_LITTLE_ENDIAN)
// endianness
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
# define ARCH_ENDIANNESS "little_endian"
#elif defined(Q_BIG_ENDIAN)
#elif Q_BYTE_ORDER == Q_BIG_ENDIAN
# define ARCH_ENDIANNESS "big_endian"
#endif

View File

@ -45,6 +45,8 @@
#include <QPair>
#include <QTextCodec>
#include <QSysInfo>
#include <QLatin1String>
class tst_QGlobal: public QObject
{
@ -65,6 +67,7 @@ private slots:
void integerForSize();
void qprintable();
void qprintable_data();
void buildAbiEndianness();
};
void tst_QGlobal::qIsNull()
@ -652,5 +655,15 @@ void tst_QGlobal::qprintable_data()
}
void tst_QGlobal::buildAbiEndianness()
{
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
QLatin1String endian("little_endian");
#elif Q_BYTE_ORDER == Q_BIG_ENDIAN
QLatin1String endian("big_endian");
#endif
QVERIFY(QSysInfo::buildAbi().contains(endian));
}
QTEST_APPLESS_MAIN(tst_QGlobal)
#include "tst_qglobal.moc"