Coder Social home page Coder Social logo

问一个非常诡异的用例 about flare HOT 10 CLOSED

tencent avatar tencent commented on May 3, 2024
问一个非常诡异的用例

from flare.

Comments (10)

0x804d8000 avatar 0x804d8000 commented on May 3, 2024 1

用cmake的话注意一下https://github.com/Tencent/flare/blob/master/flare/base/compression/BUILD#L55 link_all_symbols,对应于-Wl,--whole-archive

不然链接器可能会把自动注册的这些文件丢掉

https://stackoverflow.com/questions/805555/ld-linker-question-the-whole-archive-option

from flare.

0x804d8000 avatar 0x804d8000 commented on May 3, 2024

没太理解,是说编译以后直接运行compression_test gzip失败了吗,但是这个compression_test感觉接受不了参数啊🤔

from flare.

yinghaoyu avatar yinghaoyu commented on May 3, 2024

第1个用例SetUp()函数会读取参数的。第2个用例是正常的,作为参照。

from flare.

0x804d8000 avatar 0x804d8000 commented on May 3, 2024

我还是没理解是怎么从命令行读到的gzip,要么cout一下看看是不是真的读到了?

from flare.

yinghaoyu avatar yinghaoyu commented on May 3, 2024

./compression_test gzip这里的gzip是输入参数,看这个用例代码应该是需要入参的

  std::string Compress(
      std::function<bool(Compressor*, CompressionOutputStream* out)> f) {
    if (!with_test_output_stream_) {
      NoncontiguousBufferBuilder builder;
      NoncontiguousBufferCompressionOutputStream out(&builder);
     // Setup()函数解析后,这里method_为入参值gzip
      auto&& c = MakeCompressor(method_);  //  调试这里一直返回nullptr
      EXPECT_TRUE(c);

这是第一个用例的问题。
第二个用例是直接代码里写的MakeCompressor(“gzip”),能正常得到Compressor
两个用例同样是MakeCompressor(“gzip”),结果第一个用例在 EXPECT_TRUE(c);失败了。

from flare.

0x804d8000 avatar 0x804d8000 commented on May 3, 2024

你的执行方式是

~/flare/build64_release/flare/base/compression_test.runfiles]% LD_LIBRARY_PATH=. ../compression_test gzip

这样吗

我这样执行看起来命令行参数gzip被忽略了,跟直接执行LD_LIBRARY_PATH=. ../compression_test效果是一样的

你也可以试试把method_打出来看看是不是符合预期的内容

from flare.

yinghaoyu avatar yinghaoyu commented on May 3, 2024

你看的是第二个用例,这个是对的。我说的是第一个用例,method_打印是符合我预期的。

from flare.

0x804d8000 avatar 0x804d8000 commented on May 3, 2024

你运行的是master代码生成的flare/base/compression/compression_test吗?

我试了下不管不传命令行参数或者传命令行参数gzip,输出是一样的。而且根据我的理解,gtest也不会因为命令行传入了一个不以-开头的参数就改变行为。

from flare.

yinghaoyu avatar yinghaoyu commented on May 3, 2024

确实是master分支代码,不过我自己用cmake管理的。那就奇怪了,感觉像是auto&& c = MakeCompressor(method_);早于全局变量FLARE_COMPRESSION_REGISTER_COMPRESSOR("gzip", GzipCompressor);的初始化,只有这种情况才会出错,但是用例2却正常运行。。。

from flare.

yinghaoyu avatar yinghaoyu commented on May 3, 2024

谢谢,原来如此。

from flare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.